NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Geo Bounds Aggregation Usage
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Geo Bounds Aggregation Usage
editFluent DSL example
edita => a
.GeoBounds("viewport", gb => gb
.Field(p => p.LocationPoint)
.WrapLongitude(true)
)
Object Initializer syntax example
editnew GeoBoundsAggregation("viewport", Field<Project>(p => p.LocationPoint))
{
WrapLongitude = true
}
Example json output.
{
"viewport": {
"geo_bounds": {
"field": "locationPoint",
"wrap_longitude": true
}
}
}
Handling Responses
editresponse.ShouldBeValid();
var viewport = response.Aggregations.GeoBounds("viewport");
viewport.Should().NotBeNull();
viewport.Bounds.Should().NotBeNull();
var bottomRight = viewport.Bounds.BottomRight;
bottomRight.Should().NotBeNull();
bottomRight.Lat.Should().HaveValue();
GeoLocation.IsValidLatitude(bottomRight.Lat.Value).Should().BeTrue();
bottomRight.Lon.Should().HaveValue();
GeoLocation.IsValidLongitude(bottomRight.Lon.Value).Should().BeTrue();
var topLeft = viewport.Bounds.TopLeft;
topLeft.Should().NotBeNull();
topLeft.Lat.Should().HaveValue();
GeoLocation.IsValidLatitude(topLeft.Lat.Value).Should().BeTrue();
topLeft.Lon.Should().HaveValue();
GeoLocation.IsValidLongitude(topLeft.Lon.Value).Should().BeTrue();