/** * @group functional */ public function testAggregateWithScriptFields() { $this->_checkScriptInlineSetting(); $aggr = new TopHits('top_tag_hits'); $aggr->setSize(1); $aggr->setScriptFields(array('three' => new Script('1 + 2'))); $aggr->addScriptField('five', new Script('3 + 2')); $resultDocs = array(); $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { $this->assertEquals(3, $doc['fields']['three'][0]); $this->assertEquals(5, $doc['fields']['five'][0]); } } }