Skip to content

Commit

Permalink
Allow filter aggregation without nested aggregations
Browse files Browse the repository at this point in the history
With is useful for getting only the basic doc_count value.
  • Loading branch information
Sven Friese committed Apr 3, 2024
1 parent 4a239a0 commit 5bd2cad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Aggregations/FilterAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ public function __construct(

public function payload(): array
{
return [
$aggregation = [
'filter' => $this->filter->toArray(),
'aggs' => $this->aggregations->toArray(),
];

if (! $this->aggregations->isEmpty()) {
$aggregation['aggs'] = $this->aggregations->toArray();
}

return $aggregation;
}
}

0 comments on commit 5bd2cad

Please sign in to comment.