| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | [[java-aggs-metrics-geobounds]]==== Geo Bounds AggregationHere is how you can use{ref}/search-aggregations-metrics-geobounds-aggregation.html[Geo Bounds Aggregation]with Java API.===== Prepare aggregation requestHere is an example on how to create the aggregation request:[source,java]--------------------------------------------------GeoBoundsAggregationBuilder aggregation =        GeoBoundsAggregationBuilder                .geoBounds("agg")                .field("address.location")                .wrapLongitude(true);--------------------------------------------------===== Use aggregation responseImport Aggregation definition classes:[source,java]--------------------------------------------------import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds;--------------------------------------------------[source,java]--------------------------------------------------// sr is here your SearchResponse objectGeoBounds agg = sr.getAggregations().get("agg");GeoPoint bottomRight = agg.bottomRight();GeoPoint topLeft = agg.topLeft();logger.info("bottomRight {}, topLeft {}", bottomRight, topLeft);--------------------------------------------------This will basically produce:[source,text]--------------------------------------------------bottomRight [40.70500764381921, 13.952946866893775], topLeft [53.49603022435221, -4.190029308156676]--------------------------------------------------
 |