use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendUsingCorrectIndicesTest method queryDoesNotFallBackToUsingAllIndicesWhenNoIndexRangesAreReturned.
@Test
public void queryDoesNotFallBackToUsingAllIndicesWhenNoIndexRangesAreReturned() throws Exception {
final ESGeneratedQueryContext context = backend.generate(job, query, new SearchConfig(Period.ZERO));
backend.doRun(job, query, context);
verify(client, times(1)).msearch(clientRequestCaptor.capture(), any());
final List<SearchRequest> clientRequest = clientRequestCaptor.getValue();
assertThat(clientRequest).isNotNull();
assertThat(indicesOf(clientRequest).get(0)).isEqualTo("");
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendUsingCorrectIndicesTest method queryUsesOnlyIndicesBelongingToStream.
@Test
public void queryUsesOnlyIndicesBelongingToStream() throws Exception {
final Query query = dummyQuery(RelativeRange.create(600)).toBuilder().filter(AndFilter.and(StreamFilter.ofId("stream1"), StreamFilter.ofId("stream2"))).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("stream1", "stream2"), RelativeRange.create(600))).thenReturn(ImmutableSet.of("index1", "index2"));
backend.doRun(job, query, context);
verify(client, times(1)).msearch(clientRequestCaptor.capture(), any());
final List<SearchRequest> clientRequest = clientRequestCaptor.getValue();
assertThat(clientRequest).isNotNull();
assertThat(indicesOf(clientRequest).get(0)).isEqualTo("index1,index2");
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendQueryStringDecoratorsTest method generateJsonRequest.
private DocumentContext generateJsonRequest(Query query, SearchJob searchJob) {
final ESGeneratedQueryContext context = this.backend.generate(searchJob, query, new SearchConfig(Period.ZERO));
final String request = context.searchTypeQueries().get("testSearchtype").toString();
return JsonPath.parse(request);
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendMultiSearchTest method everySearchTypeGeneratesOneESQuery.
@Test
public void everySearchTypeGeneratesOneESQuery() throws Exception {
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 ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
final List<SearchRequest> generatedRequest = run(searchJob, query, queryContext, Collections.emptySet());
assertThat(generatedRequest).hasSize(2);
}
use of org.graylog.plugins.views.search.engine.SearchConfig in project graylog2-server by Graylog2.
the class ElasticsearchBackendMultiSearchTest method everySearchTypeGeneratesASearchSourceBuilder.
@Test
public void everySearchTypeGeneratesASearchSourceBuilder() {
final ESGeneratedQueryContext queryContext = this.elasticsearchBackend.generate(searchJob, query, new SearchConfig(Period.ZERO));
assertThat(queryContext.searchTypeQueries()).hasSize(2).containsOnlyKeys("pivot1", "pivot2");
}
Aggregations