diff --git a/Aggregation/ExtendedStatsAggregation.php b/Aggregation/ExtendedStatsAggregation.php
index 4307db4ddea6b617aaf3ea59f3bc82a9ca47adba..110e56346f06ea7d0fdec175c322cadb4a06d297 100644
--- a/Aggregation/ExtendedStatsAggregation.php
+++ b/Aggregation/ExtendedStatsAggregation.php
@@ -56,19 +56,16 @@ class ExtendedStatsAggregation extends AbstractAggregation
      */
     public function getArray()
     {
-        $out = [];
-
-        if ($this->getField()) {
-            $out['field'] = $this->getField();
-        } elseif ($this->getScript()) {
-            $out['script'] = $this->getScript();
-        } else {
-            throw new \LogicException('Extended stats aggregation must have field or script set.');
-        }
-
-        if ($this->getSigma()) {
-            $out['sigma'] = $this->getSigma();
-        }
+        $out = array_filter(
+            [
+                'field' => $this->getField(),
+                'script' => $this->getScript(),
+                'sigma' => $this->getSigma(),
+            ],
+            function ($val) {
+                return ($val || is_numeric($val));
+            }
+        );
 
         return $out;
     }