use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext in project graylog2-server by Graylog2.
the class ESPivot method processSeries.
private void processSeries(PivotResult.Row.Builder rowBuilder, SearchResponse searchResult, ESGeneratedQueryContext queryContext, Pivot pivot, ArrayDeque<String> columnKeys, HasAggregations aggregation, boolean rollup, String source) {
pivot.series().forEach(seriesSpec -> {
final ESPivotSeriesSpecHandler<? extends SeriesSpec, ? extends Aggregation> seriesHandler = seriesHandlers.get(seriesSpec.type());
final Aggregation series = seriesHandler.extractAggregationFromResult(pivot, seriesSpec, aggregation, queryContext);
seriesHandler.handleResult(pivot, seriesSpec, searchResult, series, this, queryContext).map(value -> {
columnKeys.addLast(value.id());
final PivotResult.Value v = PivotResult.Value.create(columnKeys, value.value(), rollup, source);
columnKeys.removeLast();
return v;
}).forEach(rowBuilder::addValue);
});
}
use of org.graylog.storage.elasticsearch6.views.ESGeneratedQueryContext in project graylog2-server by Graylog2.
the class ElasticsearchBackendUsingCorrectIndicesTest method setupSUT.
@Before
public void setupSUT() throws Exception {
when(jestClient.execute(any(), any())).thenReturn(resultFor(resourceFile("successfulResponseWithSingleQuery.json")));
final FieldTypesLookup fieldTypesLookup = mock(FieldTypesLookup.class);
this.backend = new ElasticsearchBackend(handlers, jestClient, indexLookup, new QueryStringDecorators.Fake(), (elasticsearchBackend, ssb, job, query) -> new ESGeneratedQueryContext(elasticsearchBackend, ssb, job, query, fieldTypesLookup), false, objectMapper);
}
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 passesTypeOfSortingFieldAsUnmappedType.
@Test
public void passesTypeOfSortingFieldAsUnmappedType() {
final MessageList messageList = someMessageListWithSorting("stream1", "somefield");
final ESGeneratedQueryContext context = mockQueryContext(messageList);
when(context.fieldType(Collections.singleton("stream1"), "somefield")).thenReturn(Optional.of("long"));
final ESGeneratedQueryContext queryContext = generateQueryPartWithContextFor(messageList, true, Collections.emptySet(), context);
final DocumentContext doc = JsonPath.parse(queryContext.searchSourceBuilder(messageList).toString());
JsonPathAssert.assertThat(doc).jsonPathAsString("$.sort[0].somefield.unmapped_type").isEqualTo("long");
}
Aggregations