diff --git a/src/Aggregation/NestedAggregation.php b/src/Aggregation/NestedAggregation.php index be5da0bed1b82e1b807400d63663ee4cf8f97f2e..f3ace96516ef1ed12467a2f258ca0749b5db9049 100644 --- a/src/Aggregation/NestedAggregation.php +++ b/src/Aggregation/NestedAggregation.php @@ -71,6 +71,10 @@ class NestedAggregation extends AbstractAggregation */ public function getArray() { + if (count($this->getAggregations()) == 0) { + throw new \LogicException("Nested aggregation `{$this->getName()}` has no aggregations added"); + } + return ['path' => $this->getPath()]; } } diff --git a/src/Aggregation/ReverseNestedAggregation.php b/src/Aggregation/ReverseNestedAggregation.php index 55b58b232e27c2b223e3eb9cf923e6ae039dace0..ac92f9ed9e4e743704b013e4d6153a7f03948f62 100644 --- a/src/Aggregation/ReverseNestedAggregation.php +++ b/src/Aggregation/ReverseNestedAggregation.php @@ -71,10 +71,6 @@ class ReverseNestedAggregation extends AbstractAggregation */ public function getArray() { - if (count($this->getAggregations()) == 0) { - throw new \LogicException("Reverse Nested aggregation `{$this->getName()}` has no aggregations added"); - } - $output = new \stdClass(); if ($this->getPath()) { $output = ['path' => $this->getPath()];