WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Geo Distance aggregation
editGeo Distance aggregation
editA multi-bucket aggregation that works on geo_point fields and conceptually works very similar to the range aggregation.
Fluent DSL
editvar result = client.Search<ElasticsearchProject>(s => s .Aggregations(a => a .GeoDistance("my_geo_distance_agg", g => g .Field(p => p.Origin) .Origin("93.57, 93.57") .Ranges( r => r.To(100), r => r.From(100).To(300), r => r.From(300) ) ) ) ); var agg = result.Aggs.GeoDistance("my_geo_distance_agg");
Object Initializer Syntax
editvar request = new SearchRequest { Aggregations = new Dictionary<string, IAggregationContainer> { { "my_geo_distance_agg", new AggregationContainer { GeoDistance = new GeoDistanceAggregator { Field = "origin", Origin = "93.57, 93.57", Ranges = new List<Range<double>> { new Range<double>().To(100), new Range<double>().From(100).To(300), new Range<double>().From(300) } } } } } }; var result = client.Search<ElasticsearchProject>(request); var agg = result.Aggs.GeoDistance("my_geo_distance_agg");
Refer to the {ref_current}/search-aggregations-bucket-geodistance-aggregation.html[original docs] for more information.