Skip to content
Snippets Groups Projects
Commit fc4709cc authored by Mantas Jonušas's avatar Mantas Jonušas
Browse files

Stats aggregation now accepts scripts

parent 9dfce177
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@
namespace ONGR\ElasticsearchBundle\DSL\Aggregation;
use ONGR\ElasticsearchBundle\DSL\Aggregation\Type\MetricTrait;
use ONGR\ElasticsearchBundle\DSL\ScriptAwareTrait;
/**
* Class representing StatsAggregation.
......@@ -19,6 +20,7 @@ use ONGR\ElasticsearchBundle\DSL\Aggregation\Type\MetricTrait;
class StatsAggregation extends AbstractAggregation
{
use MetricTrait;
use ScriptAwareTrait;
/**
* {@inheritdoc}
......@@ -33,6 +35,14 @@ class StatsAggregation extends AbstractAggregation
*/
public function getArray()
{
return $this->getField() ? ['field' => $this->getField()] : new \stdClass();
$out = [];
if ($this->getField()) {
$out['field'] = $this->getField();
}
if ($this->getScript()) {
$out['script'] = $this->getScript();
}
return $out;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment