use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchResponse in project graylog2-server by Graylog2.
the class ElasticsearchBackendSearchTypeOverridesTest method overridesInSearchTypeAreIncorporatedIntoGeneratedQueries.
@Test
public void overridesInSearchTypeAreIncorporatedIntoGeneratedQueries() throws IOException {
final ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
final MultiSearchResponse response = TestMultisearchResponse.fromFixture("successfulMultiSearchResponse.json");
final List<MultiSearchResponse.Item> items = Arrays.stream(response.getResponses()).collect(Collectors.toList());
when(client.msearch(any(), any())).thenReturn(items);
final List<SearchRequest> generatedRequest = run(searchJob, query, queryContext, Collections.emptySet());
final DocumentContext pivot1 = parse(generatedRequest.get(0).source().toString());
final DocumentContext pivot2 = parse(generatedRequest.get(1).source().toString());
assertThat(queryStrings(pivot1)).containsExactly("production:true");
assertThat(timerangeFrom(pivot1)).containsExactly("2019-09-11 10:31:52.819");
assertThat(timerangeTo(pivot1)).containsExactly("2019-09-11 10:36:52.823");
assertThat(streams(pivot1)).containsExactly(Collections.singletonList("stream1"));
assertThat(queryStrings(pivot2)).containsExactly("production:true", "source:babbage");
assertThat(timerangeFrom(pivot2)).containsExactly("2018-08-23 08:02:00.247");
assertThat(timerangeTo(pivot2)).containsExactly("2018-08-23 08:07:00.252");
assertThat(streams(pivot2)).containsExactly(Collections.singletonList("stream1"));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchResponse in project graylog2-server by Graylog2.
the class ElasticsearchBackendSearchTypeOverridesTest method timerangeOverridesAffectIndicesSelection.
@Test
public void timerangeOverridesAffectIndicesSelection() throws IOException, InvalidRangeParametersException {
when(indexLookup.indexNamesForStreamsInTimeRange(ImmutableSet.of("stream1"), timeRangeForTest())).thenReturn(ImmutableSet.of("queryIndex"));
TimeRange tr = AbsoluteRange.create("2019-09-11T10:31:52.819Z", "2019-09-11T10:36:52.823Z");
when(indexLookup.indexNamesForStreamsInTimeRange(ImmutableSet.of("stream1"), tr)).thenReturn(ImmutableSet.of("searchTypeIndex"));
final ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
final MultiSearchResponse response = TestMultisearchResponse.fromFixture("successfulMultiSearchResponse.json");
final List<MultiSearchResponse.Item> items = Arrays.stream(response.getResponses()).collect(Collectors.toList());
when(client.msearch(any(), any())).thenReturn(items);
final List<SearchRequest> generatedRequest = run(searchJob, query, queryContext, Collections.emptySet());
assertThat(indicesOf(generatedRequest)).hasSize(2).containsExactly("searchTypeIndex", "queryIndex");
}
Aggregations