use of org.elasticsearch.action.get.MultiGetRequestBuilder in project sonarqube by SonarSource.
the class ProxyMultiGetRequestBuilderTest method trace_logs.
@Test
public void trace_logs() {
logTester.setLevel(LoggerLevel.TRACE);
MultiGetRequestBuilder request = esTester.client().prepareMultiGet();
request.add(new MultiGetRequest.Item(FakeIndexDefinition.INDEX, FakeIndexDefinition.TYPE, "ruleKey").fetchSourceContext(FetchSourceContext.FETCH_SOURCE));
request.get();
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1);
}
use of org.elasticsearch.action.get.MultiGetRequestBuilder in project play2-elasticsearch by cleverage.
the class IndexService method multiGet.
/**
* Get Indexable Object for an Id
*
* @param indexPath
* @param clazz
* @return
*/
public static <T extends Index> List<T> multiGet(IndexQueryPath indexPath, Class<T> clazz, Collection<String> ids) {
MultiGetRequestBuilder multiGetRequestBuilder = getMultiGetRequestBuilder(indexPath, ids);
MultiGetResponse multiGetResponse = multiGetRequestBuilder.execute().actionGet();
return getTsFromMultiGetResponse(clazz, multiGetResponse);
}
use of org.elasticsearch.action.get.MultiGetRequestBuilder in project play2-elasticsearch by cleverage.
the class IndexService method multiGet.
/**
* Get a response for a simple request
* @param indexName
* @param indexType
* @param ids
* @return
*/
public static MultiGetResponse multiGet(String indexName, String indexType, Collection<String> ids) {
MultiGetRequestBuilder multiGetRequestBuilder = IndexClient.client.prepareMultiGet();
for (String id : ids) {
multiGetRequestBuilder.add(indexName, indexType, ids);
}
MultiGetResponse multiGetResponse = multiGetRequestBuilder.execute().actionGet();
return multiGetResponse;
}
use of org.elasticsearch.action.get.MultiGetRequestBuilder in project play2-elasticsearch by cleverage.
the class IndexService method multiGetAsync.
/**
* Get Indexable Object for an Ids asynchronously
* @param indexPath
* @param clazz
* @param ids
* @param List<T>
* @return
*/
public static <T extends Index> F.Promise<List<T>> multiGetAsync(IndexQueryPath indexPath, final Class<T> clazz, Collection<String> ids) {
MultiGetRequestBuilder multiGetRequestBuilder = getMultiGetRequestBuilder(indexPath, ids);
F.Promise<MultiGetResponse> responsePromise = AsyncUtils.executeAsyncJava(multiGetRequestBuilder);
return responsePromise.filter(null).map(new F.Function<MultiGetResponse, List<T>>() {
public List<T> apply(MultiGetResponse getResponse) {
return getTsFromMultiGetResponse(clazz, getResponse);
}
});
}
use of org.elasticsearch.action.get.MultiGetRequestBuilder in project elasticsearch by elastic.
the class BulkProcessorIT method testBulkProcessorWaitOnClose.
public void testBulkProcessorWaitOnClose() throws Exception {
BulkProcessorTestListener listener = new BulkProcessorTestListener();
int numDocs = randomIntBetween(10, 100);
BulkProcessor processor = BulkProcessor.builder(client(), listener).setName("foo").setConcurrentRequests(randomIntBetween(0, 1)).setBulkActions(numDocs).setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(randomIntBetween(1, 10), RandomPicks.randomFrom(random(), ByteSizeUnit.values()))).build();
MultiGetRequestBuilder multiGetRequestBuilder = indexDocs(client(), processor, numDocs);
assertThat(processor.isOpen(), is(true));
assertThat(processor.awaitClose(1, TimeUnit.MINUTES), is(true));
if (randomBoolean()) {
// check if we can call it multiple times
if (randomBoolean()) {
assertThat(processor.awaitClose(1, TimeUnit.MINUTES), is(true));
} else {
processor.close();
}
}
assertThat(processor.isOpen(), is(false));
assertThat(listener.beforeCounts.get(), greaterThanOrEqualTo(1));
assertThat(listener.afterCounts.get(), greaterThanOrEqualTo(1));
assertThat(listener.bulkFailures.size(), equalTo(0));
assertResponseItems(listener.bulkItems, numDocs);
assertMultiGetResponse(multiGetRequestBuilder.get(), numDocs);
}
Aggregations