diff --git a/src/Aggregation/AbstractAggregation.php b/src/Aggregation/AbstractAggregation.php index c80fc589ad..dd7e958b48 100644 --- a/src/Aggregation/AbstractAggregation.php +++ b/src/Aggregation/AbstractAggregation.php @@ -128,10 +128,6 @@ public function toArray(): array { $array = parent::toArray(); - if (\array_key_exists('global_aggregation', $array)) { - // compensate for class name GlobalAggregation - $array = ['global' => new \stdClass()]; - } if (\count($this->_aggs)) { $array['aggs'] = $this->_convertArrayable($this->_aggs); } diff --git a/src/Aggregation/GlobalAggregation.php b/src/Aggregation/GlobalAggregation.php index 0e64e362b8..41c3d627f4 100644 --- a/src/Aggregation/GlobalAggregation.php +++ b/src/Aggregation/GlobalAggregation.php @@ -9,4 +9,8 @@ */ class GlobalAggregation extends AbstractAggregation { + protected function _getBaseName() + { + return 'global'; + } } diff --git a/tests/Aggregation/GlobalAggregationTest.php b/tests/Aggregation/GlobalAggregationTest.php index 5d5f007947..d8b14fe247 100644 --- a/tests/Aggregation/GlobalAggregationTest.php +++ b/tests/Aggregation/GlobalAggregationTest.php @@ -16,7 +16,7 @@ class GlobalAggregationTest extends BaseAggregationTest public function testToArray(): void { $expected = [ - 'global' => new \stdClass(), + 'global' => [], 'aggs' => [ 'avg_price' => ['avg' => ['field' => 'price']], ],