diff --git a/src/Aggregation/GeoDistanceAggregation.php b/src/Aggregation/GeoDistanceAggregation.php index d360bdf4b2a14bf9d39fce728ec84841e5a646d8..b9a0e6fe99a9dfce6e2746cf82ecaf464b565e8f 100644 --- a/src/Aggregation/GeoDistanceAggregation.php +++ b/src/Aggregation/GeoDistanceAggregation.php @@ -40,6 +40,31 @@ class GeoDistanceAggregation extends AbstractAggregation */ private $ranges = []; + /** + * Inner aggregations container init. + * + * @param string $name + * @param string $field + * @param mixed $origin + * @param array $ranges + * @param string $unit + * @param string $distanceType + */ + public function __construct($name, $field = null, $origin = null, $ranges = [], $unit = null, $distanceType = null) + { + parent::__construct($name); + + $this->setField($field); + $this->setOrigin($origin); + foreach ($ranges as $range) { + $from = isset($range['from']) ? $range['from'] : null; + $to = isset($range['to']) ? $range['to'] : null; + $this->addRange($from, $to); + } + $this->setUnit($unit); + $this->setDistanceType($distanceType); + } + /** * @return string */