Search in sources :

Example 6 with HasAggregations

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.HasAggregations in project graylog2-server by Graylog2.

the class ESPivot method doExtractResult.

@Override
public SearchType.Result doExtractResult(SearchJob job, Query query, Pivot pivot, SearchResponse queryResult, Aggregations aggregations, ESGeneratedQueryContext queryContext) {
    final AbsoluteRange effectiveTimerange = extractEffectiveTimeRange(queryResult, query, pivot);
    final PivotResult.Builder resultBuilder = PivotResult.builder().id(pivot.id()).effectiveTimerange(effectiveTimerange).total(extractDocumentCount(queryResult, pivot, queryContext));
    // pivot results are a table where cells can contain multiple "values" and not only scalars:
    // each combination of row and column groups can contain all series (if rollup is true)
    // if rollup is false, only the "leaf" components contain the series
    // in the elasticsearch result, rows and columns are simply nested aggregations (first aggregations from rows, then from columns)
    // with metric aggregations on the corresponding levels.
    // first we iterate over all row groups (whose values generate a "key array", corresponding to the nesting level)
    // once we exhaust the row groups, we descend into the columns, which get added as values to their corresponding rows
    // on each nesting level and combination we have to check for series which we also add as values to the containing row
    final HasAggregations initialResult = createInitialResult(queryResult);
    processRows(resultBuilder, queryResult, queryContext, pivot, pivot.rowGroups(), new ArrayDeque<>(), initialResult);
    return pivot.name().map(resultBuilder::name).orElse(resultBuilder).build();
}
Also used : PivotResult(org.graylog.plugins.views.search.searchtypes.pivot.PivotResult) AbsoluteRange(org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange) HasAggregations(org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.HasAggregations)

Aggregations

BucketSpec (org.graylog.plugins.views.search.searchtypes.pivot.BucketSpec)3 Aggregation (org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.Aggregation)3 Preconditions (com.google.common.base.Preconditions)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Stream (java.util.stream.Stream)2 PivotResult (org.graylog.plugins.views.search.searchtypes.pivot.PivotResult)2 HasAggregations (org.graylog.shaded.elasticsearch7.org.elasticsearch.search.aggregations.HasAggregations)2 AbsoluteRange (org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableList (com.google.common.collect.ImmutableList)1 String.format (java.lang.String.format)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1 Date (java.util.Date)1