diff --git a/src/Aggregation/TopHitsAggregation.php b/src/Aggregation/TopHitsAggregation.php index 03f525d63dc16a1db720a19e3c5f6a49e6c4fc8f..0212be360f0d7f693a3b93c71726a44ccf83d738 100644 --- a/src/Aggregation/TopHitsAggregation.php +++ b/src/Aggregation/TopHitsAggregation.php @@ -153,6 +153,6 @@ class TopHitsAggregation extends AbstractAggregation } ); - return $fd; + return $this->processArray($fd); } } diff --git a/tests/Aggregation/TopHitsAggregationTest.php b/tests/Aggregation/TopHitsAggregationTest.php index a1975eb647aa3b80436fa30128eadda20b816ad9..1f01013c3756510d269b8a0c651659020a134c4c 100644 --- a/tests/Aggregation/TopHitsAggregationTest.php +++ b/tests/Aggregation/TopHitsAggregationTest.php @@ -39,4 +39,23 @@ class TopHitsAggregationTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $aggregation->toArray()); } + + /** + * Tests if adding parameters has any effect. + */ + public function testParameters() + { + $topHitsAggregation = new TopHitsAggregation('test'); + $topHitsAggregation->addParameter('_source', ['include' => ['title']]); + $expectedAgg = new \stdClass(); + $expectedAgg->sort = []; + $expectedAgg->_source = ['include' => ['title']]; + $expected = [ + 'agg_test' => [ + 'top_hits' => $expectedAgg, + ], + ]; + + $this->assertEquals($expected, $topHitsAggregation->toArray()); + } }