Skip to content

Commit

Permalink
Add support for getting aggregations on nested aggregation results
Browse files Browse the repository at this point in the history
  • Loading branch information
enrise-mbraam committed Sep 12, 2023
1 parent 5bca9bc commit 104ff70
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Application/Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ public function aggregations(): array
$aggregations = [];

foreach ($this->rawResults['aggregations'] as $name => $rawAggregation) {
if (array_key_exists('doc_count', $rawAggregation)) {
foreach ($rawAggregation as $nestedAggregationName => $rawNestedAggregation) {
if (isset($rawNestedAggregation['buckets'])) {
$aggregations[] = new AggregationResult($nestedAggregationName, $rawNestedAggregation['buckets']);
}
}
continue;
}

$aggregations[] = new AggregationResult($name, $rawAggregation['buckets']);
}

Expand Down

0 comments on commit 104ff70

Please sign in to comment.