IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Geo Distance Aggregation Usage
editGeo Distance Aggregation Usage
editFluent DSL example
edita => a .GeoDistance("rings_around_amsterdam", g => g .Field(p => p.LocationPoint) .Origin(52.376, 4.894) .Ranges( r => r.To(100), r => r.From(100).To(300), r => r.From(300) ) )
Object Initializer syntax example
editnew GeoDistanceAggregation("rings_around_amsterdam") { Field = Field((Project p) => p.LocationPoint), Origin = "52.376, 4.894", Ranges = new List<AggregationRange> { new AggregationRange { To = 100 }, new AggregationRange { From = 100, To = 300 }, new AggregationRange { From = 300 } } }
Example json output.
{ "rings_around_amsterdam": { "geo_distance": { "field": "locationPoint", "origin": { "lat": 52.376, "lon": 4.894 }, "ranges": [ { "to": 100.0 }, { "from": 100.0, "to": 300.0 }, { "from": 300.0 } ] } } }
Handling Responses
editresponse.ShouldBeValid(); var ringsAroundAmsterdam = response.Aggregations.GeoDistance("rings_around_amsterdam"); ringsAroundAmsterdam.Should().NotBeNull(); ringsAroundAmsterdam.Buckets.FirstOrDefault(r => r.Key == "*-100.0").Should().NotBeNull(); ringsAroundAmsterdam.Buckets.FirstOrDefault(r => r.Key == "100.0-300.0").Should().NotBeNull(); ringsAroundAmsterdam.Buckets.FirstOrDefault(r => r.Key == "300.0-*").Should().NotBeNull();