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 generateAppliesQueryStringDecorators.
@Test
void generateAppliesQueryStringDecorators() throws Exception {
final Query query = mock(Query.class);
final SearchJob searchJob = searchJobWithRootQueryString(query);
final DocumentContext request = generateJsonRequest(query, searchJob);
assertThat(request).jsonPathAsString(PATH_TO_QUERY_STRING).isEqualTo("decorated");
}
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");
}
use of org.graylog.plugins.views.search.SearchJob in project graylog2-server by Graylog2.
the class ElasticsearchBackendSearchTypesWithStreamsOverridesTest method run.
private MultiSearch run(Query query) throws IOException {
final SearchJob job = searchJobForQuery(query);
final ESGeneratedQueryContext context = this.elasticsearchBackend.generate(job, query, new SearchConfig(Period.ZERO));
this.elasticsearchBackend.doRun(job, query, context);
verify(jestClient, times(1)).execute(clientRequestCaptor.capture(), any());
return clientRequestCaptor.getValue();
}
use of org.graylog.plugins.views.search.SearchJob in project graylog2-server by Graylog2.
the class ESEventListTest method testSortingOfStreamsInDoExtractResult.
@Test
public void testSortingOfStreamsInDoExtractResult() {
final ESEventList esEventList = new TestESEventList();
final SearchJob searchJob = mock(SearchJob.class);
final Query query = mock(Query.class);
final SearchResult searchResult = mock(SearchResult.class);
final MetricAggregation metricAggregation = mock(MetricAggregation.class);
final ESGeneratedQueryContext queryContext = mock(ESGeneratedQueryContext.class);
final EventList eventList = EventList.builder().id("search-type-id").streams(ImmutableSet.of("stream-id-1", "stream-id-2")).build();
final EventList.Result eventResult = (EventList.Result) esEventList.doExtractResult(searchJob, query, eventList, searchResult, metricAggregation, queryContext);
assertThat(eventResult.events()).containsExactly(eventSummary("find-1", ImmutableSet.of("stream-id-1")), eventSummary("find-2", ImmutableSet.of("stream-id-2")), eventSummary("find-3", ImmutableSet.of("stream-id-1", "stream-id-2")));
}
Aggregations