Search in sources :

Example 21 with MultiSearchResponse

use of 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");
}
Also used : TimeRange(org.graylog2.plugin.indexer.searches.timeranges.TimeRange) DerivedTimeRange(org.graylog.plugins.views.search.timeranges.DerivedTimeRange) MultiSearchResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchResponse) SearchRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) Test(org.junit.Test)

Aggregations

MultiSearchResponse (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.MultiSearchResponse)13 Test (org.junit.Test)10 MultiSearchResponse (org.elasticsearch.action.search.MultiSearchResponse)8 SearchConfig (org.graylog.plugins.views.search.engine.SearchConfig)8 QueryResult (org.graylog.plugins.views.search.QueryResult)6 SearchRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.search.SearchRequest)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 Arrays (java.util.Arrays)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 Provider (javax.inject.Provider)3 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)3 Query (org.graylog.plugins.views.search.Query)3 SearchJob (org.graylog.plugins.views.search.SearchJob)3 SearchType (org.graylog.plugins.views.search.SearchType)3 IndexLookup (org.graylog.plugins.views.search.elasticsearch.IndexLookup)3 QueryStringDecorators (org.graylog.plugins.views.search.elasticsearch.QueryStringDecorators)3 SearchTypeError (org.graylog.plugins.views.search.errors.SearchTypeError)3