Skip to content
Snippets Groups Projects
Commit da6f4a6e authored by Simonas Šerlinskas's avatar Simonas Šerlinskas
Browse files

Merge pull request #321 from chyzas/patch-extended-stats-aggregation

Updated extended stats aggregation
parents 97c8881f 52525e18
No related branches found
No related tags found
No related merge requests found
...@@ -56,19 +56,16 @@ class ExtendedStatsAggregation extends AbstractAggregation ...@@ -56,19 +56,16 @@ class ExtendedStatsAggregation extends AbstractAggregation
*/ */
public function getArray() public function getArray()
{ {
$out = []; $out = array_filter(
[
if ($this->getField()) { 'field' => $this->getField(),
$out['field'] = $this->getField(); 'script' => $this->getScript(),
} elseif ($this->getScript()) { 'sigma' => $this->getSigma(),
$out['script'] = $this->getScript(); ],
} else { function ($val) {
throw new \LogicException('Extended stats aggregation must have field or script set.'); return ($val || is_numeric($val));
} }
);
if ($this->getSigma()) {
$out['sigma'] = $this->getSigma();
}
return $out; 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