diff --git a/Aggregation/AbstractAggregation.php b/Aggregation/AbstractAggregation.php index 110a4a54fa85001923a6ea0e1e520877395bb0d0..3dff51ff7679722c54495396b8dba809abca4196 100644 --- a/Aggregation/AbstractAggregation.php +++ b/Aggregation/AbstractAggregation.php @@ -13,12 +13,15 @@ namespace ONGR\ElasticsearchBundle\DSL\Aggregation; use ONGR\ElasticsearchBundle\DSL\NamedBuilderBag; use ONGR\ElasticsearchBundle\DSL\NamedBuilderInterface; +use ONGR\ElasticsearchBundle\DSL\ParametersTrait; /** * AbstractAggregation class. */ abstract class AbstractAggregation implements NamedBuilderInterface { + use ParametersTrait; + const PREFIX = 'agg_'; /** @@ -113,7 +116,12 @@ abstract class AbstractAggregation implements NamedBuilderInterface */ public function toArray() { - $result = [$this->getName() => [$this->getType() => $this->getArray()]]; + $array = $this->getArray(); + $result = [ + $this->getName() => [ + $this->getType() => is_array($array) ? $this->processArray($array) : $array, + ], + ]; if ($this->supportsNesting()) { $nestedResult = $this->collectNestedAggregations(); diff --git a/Aggregation/TermsAggregation.php b/Aggregation/TermsAggregation.php index 493189e3c7731a26aaba427262599db5c9c715ab..a12ec388c2c708da74edef14d355241f658338a8 100644 --- a/Aggregation/TermsAggregation.php +++ b/Aggregation/TermsAggregation.php @@ -12,7 +12,6 @@ namespace ONGR\ElasticsearchBundle\DSL\Aggregation; use ONGR\ElasticsearchBundle\DSL\Aggregation\Type\BucketingTrait; -use ONGR\ElasticsearchBundle\DSL\ParametersTrait; use ONGR\ElasticsearchBundle\DSL\ScriptAwareTrait; /** @@ -22,7 +21,6 @@ class TermsAggregation extends AbstractAggregation { use BucketingTrait; use ScriptAwareTrait; - use ParametersTrait; /** * {@inheritdoc} @@ -44,6 +42,6 @@ class TermsAggregation extends AbstractAggregation ] ); - return $this->processArray($data); + return $data; } }