Search in sources :

Example 6 with MultiSearch

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");
}
Also used : Query(org.graylog.plugins.views.search.Query) MultiSearch(io.searchbox.core.MultiSearch) Test(org.junit.Test)

Example 7 with MultiSearch

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");
}
Also used : Query(org.graylog.plugins.views.search.Query) MultiSearch(io.searchbox.core.MultiSearch) Test(org.junit.Test)

Example 8 with MultiSearch

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());
}
Also used : MultiSearch(io.searchbox.core.MultiSearch)

Example 9 with MultiSearch

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");
}
Also used : Query(org.graylog.plugins.views.search.Query) Search(org.graylog.plugins.views.search.Search) MultiSearch(io.searchbox.core.MultiSearch) SearchJob(org.graylog.plugins.views.search.SearchJob) ElasticsearchQueryString(org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString) SearchConfig(org.graylog.plugins.views.search.engine.SearchConfig) MultiSearch(io.searchbox.core.MultiSearch) Test(org.junit.Test)

Aggregations

MultiSearch (io.searchbox.core.MultiSearch)9 Test (org.junit.Test)7 Query (org.graylog.plugins.views.search.Query)6 SearchConfig (org.graylog.plugins.views.search.engine.SearchConfig)3 Search (org.graylog.plugins.views.search.Search)2 SearchJob (org.graylog.plugins.views.search.SearchJob)2 MultiSearchResult (io.searchbox.core.MultiSearchResult)1 Search (io.searchbox.core.Search)1 ElasticsearchQueryString (org.graylog.plugins.views.search.elasticsearch.ElasticsearchQueryString)1 SearchSourceBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder)1