/**
  * Test for extended stats aggregation with script.
  */
 public function testExtendedStatsAggregationWithScriptSet()
 {
     $repo = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $aggregation = new ExtendedStatsAggregation('test_agg');
     $aggregation->setScript("doc['product.price'].value * 1.5");
     $search = $repo->createSearch()->addAggregation($aggregation);
     $results = $repo->execute($search, Repository::RESULTS_RAW);
     $expectedResult = ['agg_test_agg' => ['count' => 3, 'min' => 15.67, 'max' => 48, 'avg' => 28.78, 'sum' => 86.33, 'sum_of_squares' => 3062.73, 'variance' => 192.91, 'std_deviation' => 13.89, 'std_deviation_bounds' => ['upper' => 56.55, 'lower' => 0.99]]];
     $this->assertEquals($expectedResult, $results['aggregations'], '', 0.01);
 }
 /**
  * Test for extended stats aggregation with script set.
  */
 public function testExtendedStatsAggregationWithScriptSet()
 {
     $repo = $this->getManager()->getRepository('AcmeTestBundle:Product');
     $aggregation = new ExtendedStatsAggregation('test_agg');
     $aggregation->setScript("doc['product.price'].value * 1.5");
     $search = $repo->createSearch()->addAggregation($aggregation);
     $results = $repo->execute($search, Repository::RESULTS_RAW);
     $expectedMin = 15.675;
     $this->assertEquals($expectedMin, $results['aggregations'][$aggregation->getName()]['min'], '', 0.01);
 }