Search in sources :

Example 1 with GetRequestBuilder

use of org.elasticsearch.action.get.GetRequestBuilder in project sonarqube by SonarSource.

the class UserIndex method getNullableByLogin.

@CheckForNull
public UserDoc getNullableByLogin(String login) {
    GetRequestBuilder request = esClient.prepareGet(UserIndexDefinition.INDEX_TYPE_USER, login).setFetchSource(true).setRouting(login);
    GetResponse response = request.get();
    if (response.isExists()) {
        return DOC_CONVERTER.apply(response.getSource());
    }
    return null;
}
Also used : GetResponse(org.elasticsearch.action.get.GetResponse) GetRequestBuilder(org.elasticsearch.action.get.GetRequestBuilder) CheckForNull(javax.annotation.CheckForNull)

Example 2 with GetRequestBuilder

use of org.elasticsearch.action.get.GetRequestBuilder in project play2-elasticsearch by cleverage.

the class IndexService method get.

/**
     * Get Indexable Object for an Id
     *
     * @param indexPath
     * @param clazz
     * @return
     */
public static <T extends Index> T get(IndexQueryPath indexPath, Class<T> clazz, String id) {
    GetRequestBuilder getRequestBuilder = getGetRequestBuilder(indexPath, id);
    GetResponse getResponse = getRequestBuilder.execute().actionGet();
    return getTFromGetResponse(clazz, getResponse);
}
Also used : GetResponse(org.elasticsearch.action.get.GetResponse) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) GetRequestBuilder(org.elasticsearch.action.get.GetRequestBuilder)

Example 3 with GetRequestBuilder

use of org.elasticsearch.action.get.GetRequestBuilder in project sonarqube by SonarSource.

the class ProxyGetRequestBuilderTest method fail_to_get_bad_query.

@Test
public void fail_to_get_bad_query() {
    GetRequestBuilder requestBuilder = esTester.client().prepareGet().setIndex("unknown").setType("test").setId("rule1");
    try {
        requestBuilder.get();
        fail();
    } catch (Exception e) {
        assertThat(e).isInstanceOf(IllegalStateException.class);
        assertThat(e.getMessage()).contains("Fail to execute ES get request for key 'rule1' on index 'unknown' on type 'test'");
    }
}
Also used : GetRequestBuilder(org.elasticsearch.action.get.GetRequestBuilder) Test(org.junit.Test)

Example 4 with GetRequestBuilder

use of org.elasticsearch.action.get.GetRequestBuilder in project fess by codelibs.

the class FessEsClient method get.

protected <T> T get(final String index, final String type, final String id, final SearchCondition<GetRequestBuilder> condition, final SearchResult<T, GetRequestBuilder, GetResponse> searchResult) {
    final long startTime = System.currentTimeMillis();
    GetResponse response = null;
    final GetRequestBuilder requestBuilder = client.prepareGet(index, type, id);
    if (condition.build(requestBuilder)) {
        response = requestBuilder.execute().actionGet(ComponentUtil.getFessConfig().getIndexSearchTimeout());
    }
    final long execTime = System.currentTimeMillis() - startTime;
    return searchResult.build(requestBuilder, execTime, OptionalEntity.ofNullable(response, () -> {
    }));
}
Also used : GetResponse(org.elasticsearch.action.get.GetResponse) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) GetRequestBuilder(org.elasticsearch.action.get.GetRequestBuilder)

Example 5 with GetRequestBuilder

use of org.elasticsearch.action.get.GetRequestBuilder in project play2-elasticsearch by cleverage.

the class IndexService method get.

/**
     * Get a reponse for a simple request
     * @param indexName
     * @param indexType
     * @param id
     * @return
     */
public static GetResponse get(String indexName, String indexType, String id) {
    GetRequestBuilder getRequestBuilder = IndexClient.client.prepareGet(indexName, indexType, id);
    GetResponse getResponse = getRequestBuilder.execute().actionGet();
    return getResponse;
}
Also used : GetResponse(org.elasticsearch.action.get.GetResponse) MultiGetResponse(org.elasticsearch.action.get.MultiGetResponse) MultiGetRequestBuilder(org.elasticsearch.action.get.MultiGetRequestBuilder) GetRequestBuilder(org.elasticsearch.action.get.GetRequestBuilder)

Aggregations

GetRequestBuilder (org.elasticsearch.action.get.GetRequestBuilder)5 GetResponse (org.elasticsearch.action.get.GetResponse)4 MultiGetRequestBuilder (org.elasticsearch.action.get.MultiGetRequestBuilder)3 MultiGetResponse (org.elasticsearch.action.get.MultiGetResponse)3 CheckForNull (javax.annotation.CheckForNull)1 Test (org.junit.Test)1