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;
}
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);
}
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'");
}
}
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, () -> {
}));
}
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;
}
Aggregations