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();
}
Aggregations