From be90ef3ca02b030f62cfc21af83c7604e185ff0f Mon Sep 17 00:00:00 2001 From: Aivaras Gotovskis <aivaras.gotovskis@ongr.io> Date: Thu, 9 Jul 2015 16:41:03 +0300 Subject: [PATCH] Add geo distance aggregation doc. --- docs/Aggregation/GeoDistance.md | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 docs/Aggregation/GeoDistance.md diff --git a/docs/Aggregation/GeoDistance.md b/docs/Aggregation/GeoDistance.md new file mode 100644 index 0000000..5f4eea5 --- /dev/null +++ b/docs/Aggregation/GeoDistance.md @@ -0,0 +1,48 @@ +# Geo Distance Aggregation + +> More info about geo distance aggregation is in the [official elasticsearch docs][1] + +A multi-bucket aggregation that works on geo_point fields +and conceptually works very similar to the range aggregation. + +## Simple example + +```JSON +{ + "aggregations" : { + "rings_around_amsterdam" : { + "geo_distance" : { + "field" : "location", + "origin" : "52.3760, 4.894", + "ranges" : [ + { "to" : 100 }, + { "from" : 100, "to" : 300 }, + { "from" : 300 } + ] + } + } + } +} +``` + +And now the query via DSL: + +```php +$geoDistanceAggregation = new GeoDistanceAggregation( + 'rings_around_amsterdam', + 'location', + '52.3760, 4.894', + [ + ['to' => 100], + ['from' => 100, 'to' => 300], + ['from' => 300], + ] +); + +$search = new Search(); +$search->addAggregation($geoDistanceAggregation); + +$queryArray = $search->toArray(); +``` + +[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html -- GitLab