use of org.graylog.plugins.views.search.SearchJob in project graylog2-server by Graylog2.
the class ElasticsearchBackendUsingCorrectIndicesTest method before.
@Before
public void before() throws Exception {
this.query = Query.builder().id("query1").timerange(RelativeRange.create(600)).query(ElasticsearchQueryString.of("*")).searchTypes(ImmutableSet.of(MessageList.builder().id("1").build())).build();
final Search search = Search.builder().id("search1").queries(ImmutableSet.of(query)).build();
this.job = new SearchJob("job1", search, "admin");
}
use of org.graylog.plugins.views.search.SearchJob 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.SearchJob in project graylog2-server by Graylog2.
the class ElasticsearchBackendQueryStringDecoratorsTest method searchJobWithRootQueryString.
private SearchJob searchJobWithRootQueryString(Query query) throws InvalidRangeParametersException {
final SearchType searchType = basicSearchType();
final SearchJob searchJob = basicSearchJob(query, searchType);
when(query.query()).thenReturn(ElasticsearchQueryString.of("*"));
return searchJob;
}
use of org.graylog.plugins.views.search.SearchJob in project graylog2-server by Graylog2.
the class ElasticsearchBackendQueryStringDecoratorsTest method searchJobWithSearchTypeQueryString.
private SearchJob searchJobWithSearchTypeQueryString(Query query) throws InvalidRangeParametersException {
final SearchType searchType = basicSearchType();
final SearchJob searchJob = basicSearchJob(query, searchType);
when(query.query()).thenReturn(ElasticsearchQueryString.of("*"));
when(searchType.query()).thenReturn(Optional.of(ElasticsearchQueryString.of("Should never show up")));
return searchJob;
}
use of org.graylog.plugins.views.search.SearchJob in project graylog2-server by Graylog2.
the class ElasticsearchBackendQueryStringDecoratorsTest method generateAppliesQueryStringDecoratorsOnSearchTypes.
@Test
void generateAppliesQueryStringDecoratorsOnSearchTypes() throws Exception {
final Query query = mock(Query.class);
final SearchJob searchJob = searchJobWithSearchTypeQueryString(query);
final DocumentContext request = generateJsonRequest(query, searchJob);
assertThat(request).jsonPathAsString(PATH_TO_QUERY_STRING).isEqualTo("decorated");
}
Aggregations