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 aggregationedit
A multi-bucket aggregation that works on geo_point fields and conceptually works very similar to the range aggregation.
Fluent DSLedit
var 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 Syntaxedit
var 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.