コード例 #1
0
ファイル: GetTest.java プロジェクト: ChrisBono/es-client-java
  @Test
  public void testGetSlash() {
    final String id = "get-test/id-2";
    final IndexRequestBuilder indexRequestBuilder =
        restClient().prepareIndex(index, type, id).setSource("field", "value").setRefresh(true);
    indexRequestBuilder.execute().actionGet();

    final GetRequestBuilder getRequestBuilder = restClient().prepareGet(index, type, id);
    final ListenableActionFuture<GetResponse> execute1 = getRequestBuilder.execute();
    final GetResponse get = execute1.actionGet();
    assertEquals(get.getIndex(), index);
    assertEquals(get.getType(), type);
    assertEquals(get.getId(), id);
    assertEquals(get.getVersion(), 1);
    assertTrue(get.getFields().isEmpty());
    assertEquals(get.getSource().get("field"), "value");
  }
コード例 #2
0
ファイル: BaseIndex.java プロジェクト: ihr/sonarqube
  @CheckForNull
  @Override
  public DOMAIN getNullableByKey(KEY key) {
    GetRequestBuilder request =
        client
            .prepareGet()
            .setType(this.getIndexType())
            .setIndex(this.getIndexName())
            .setId(this.getKeyValue(key))
            .setFetchSource(true)
            .setRouting(this.getKeyValue(key));

    GetResponse response = request.get();

    if (response.isExists()) {
      return toDoc(response.getSource());
    }
    return null;
  }
コード例 #3
0
  /**
   * Get the river definition by its name
   *
   * @param name
   * @return
   */
  public T get(String name) {
    if (logger.isDebugEnabled()) logger.debug("get({})", name);
    T river = null;

    if (name != null) {
      GetRequestBuilder rb = new GetRequestBuilder(client, SMDSearchProperties.ES_META_INDEX);
      rb.setType(SMDSearchProperties.ES_META_RIVERS);
      rb.setId(name);

      try {
        GetResponse response = rb.execute().actionGet();
        if (response.isExists()) {
          river = getHelper().toRiver(buildInstance(), response.getSourceAsMap());
        }
      } catch (IndexMissingException e) {
        // Index does not exists, so RIVER does not exist...
      }
    }

    if (logger.isDebugEnabled()) logger.debug("/get({})={}", name, river);
    return river;
  }