From 7e3fc57c0f947ecf1bf8d3136c7beda1a82bb194 Mon Sep 17 00:00:00 2001 From: alex <alex@ansata.biz> Date: Wed, 14 Sep 2016 03:17:02 +0300 Subject: [PATCH] Fixes nested and reverse nested aggregation requirements --- src/Aggregation/NestedAggregation.php | 4 ++++ src/Aggregation/ReverseNestedAggregation.php | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Aggregation/NestedAggregation.php b/src/Aggregation/NestedAggregation.php index be5da0b..f3ace96 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 55b58b2..ac92f9e 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()]; -- GitLab