Skip to content
Snippets Groups Projects
Commit 71bb60d5 authored by Mantas's avatar Mantas
Browse files

added geo centroid aggregation

parent 0745aebc
No related branches found
No related tags found
No related merge requests found
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\ElasticsearchDSL\Aggregation;
use ONGR\ElasticsearchDSL\Aggregation\Type\MetricTrait;
/**
* Class representing geo centroid aggregation.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geocentroid-aggregation.html
*/
class GeoCentroidAggregation extends AbstractAggregation
{
use MetricTrait;
/**
* Inner aggregations container init.
*
* @param string $name
* @param string $field
*/
public function __construct($name, $field = null)
{
parent::__construct($name);
$this->setField($field);
}
/**
* {@inheritdoc}
*/
public function getArray()
{
$data = [];
if ($this->getField()) {
$data['field'] = $this->getField();
} else {
throw new \LogicException('Geo centroid aggregation must have a field set.');
}
return $data;
}
/**
* {@inheritdoc}
*/
public function getType()
{
return 'geo_centroid';
}
}
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