use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext 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 SearchResponse searchResult = mock(SearchResponse.class);
final Aggregations metricAggregation = mock(Aggregations.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")));
}
use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext in project graylog2-server by Graylog2.
the class ESMessageListTest method mockQueryContext.
private ESGeneratedQueryContext mockQueryContext(MessageList messageList) {
ESGeneratedQueryContext context = mock(ESGeneratedQueryContext.class);
when(context.searchSourceBuilder(messageList)).thenReturn(new SearchSourceBuilder());
return context;
}
use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext in project graylog2-server by Graylog2.
the class ESMessageListTest method appliesDecoratorsToQueryStringIfHighlightingActivated.
@Test
public void appliesDecoratorsToQueryStringIfHighlightingActivated() {
final QueryStringDecorator queryStringDecorator = (String queryString, ParameterProvider job, Query query) -> "Foobar!";
final MessageList messageList = someMessageList();
ESGeneratedQueryContext queryContext = generateQueryPartWithHighlighting(messageList, Collections.singleton(queryStringDecorator));
final DocumentContext doc = JsonPath.parse(queryContext.searchSourceBuilder(messageList).toString());
JsonPathAssert.assertThat(doc).jsonPathAsString("$.highlight.highlight_query.query_string.query").isEqualTo("Foobar!");
}
use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext in project graylog2-server by Graylog2.
the class ESMessageListTest method usesHighlightingIfActivatedInConfig.
@Test
public void usesHighlightingIfActivatedInConfig() {
MessageList messageList = someMessageList();
ESGeneratedQueryContext context = generateQueryPartWithHighlighting(messageList);
assertThat(context.searchSourceBuilder(messageList).highlighter()).isNotNull();
}
Aggregations