use of io.searchbox.core.MultiSearch in project graylog2-server by Graylog2.
the class ElasticsearchBackendSearchTypesWithStreamsOverridesTest method queryWithMixedPresenceOfOverridesIncludesMultipleSetsOfIndices.
@Test
public void queryWithMixedPresenceOfOverridesIncludesMultipleSetsOfIndices() throws IOException {
final Query query = queryFor(Pivot.builder().id("pivot1").series(Collections.singletonList(Average.builder().field("field1").build())).rollup(true).streams(Collections.singleton(stream2Id)).build(), Pivot.builder().id("pivot2").series(Collections.singletonList(Max.builder().field("field2").build())).rollup(true).streams(Collections.emptySet()).build());
final MultiSearch request = run(query);
assertThat(indicesOf(request).get(0)).isEqualTo("index3");
assertThat(indicesOf(request).get(1)).isEqualTo("index1,index2");
}
use of io.searchbox.core.MultiSearch in project graylog2-server by Graylog2.
the class ElasticsearchBackendSearchTypesWithStreamsOverridesTest method searchTypeWithStreamsOverridesQueriesStreams.
@Test
public void searchTypeWithStreamsOverridesQueriesStreams() throws IOException {
final Query query = queryFor(Pivot.builder().id("pivot1").series(Collections.singletonList(Average.builder().field("field1").build())).rollup(true).streams(Collections.singleton(stream2Id)).build());
final MultiSearch request = run(query);
assertThat(indicesOf(request).get(0)).isEqualTo("index3");
}
use of io.searchbox.core.MultiSearch in project graylog2-server by Graylog2.
the class ElasticsearchBackendGeneratedRequestTestBase method run.
String run(SearchJob searchJob, Query query, ESGeneratedQueryContext queryContext, Set<QueryResult> predecessorResults) throws IOException {
this.elasticsearchBackend.doRun(searchJob, query, queryContext);
verify(jestClient, times(1)).execute(clientRequestCaptor.capture(), any());
final MultiSearch generatedSearch = clientRequestCaptor.getValue();
return generatedSearch.getData(objectMapperProvider.get());
}
use of io.searchbox.core.MultiSearch in project graylog2-server by Graylog2.
the class ElasticsearchBackendUsingCorrectIndicesTest method queryUsesOnlyIndicesIncludingTimerangeAndStream.
@Test
public void queryUsesOnlyIndicesIncludingTimerangeAndStream() throws Exception {
final String streamId = "streamId";
final Query query = dummyQuery(RelativeRange.create(600)).toBuilder().filter(StreamFilter.ofId(streamId)).build();
final Search search = dummySearch(query);
final SearchJob job = new SearchJob("job1", search, "admin");
final ESGeneratedQueryContext context = backend.generate(job, query, new SearchConfig(Period.ZERO));
when(indexLookup.indexNamesForStreamsInTimeRange(ImmutableSet.of("streamId"), RelativeRange.create(600))).thenReturn(ImmutableSet.of("index1", "index2"));
backend.doRun(job, query, context);
verify(jestClient, times(1)).execute(clientRequestCaptor.capture(), any());
final MultiSearch clientRequest = clientRequestCaptor.getValue();
assertThat(clientRequest).isNotNull();
assertThat(indicesOf(clientRequest).get(0)).isEqualTo("index1,index2");
}
Aggregations