OpenSearch/docs/java-api/aggregations/metrics/geobounds-aggregation.asciidoc
David Pilato d7d937300a Add java documentation for aggregations
Buckets:
--------

* terms
* range
* global
* filter
* filters
* missing
* nested
* reverse nested
* children
* significant terms
* date range
* ip range
* range
* histogram
* date histogram
* geo distance
* geo hash grid

Metrics:
--------

* min
* max
* sum
* avg
* stats
* extended stats
* value count
* percentiles
* percentile rank
* cardinality
* geo bounds
* top hits
* scripted metric
2014-11-29 19:46:33 +01:00

47 lines
1.4 KiB
Plaintext

[[java-aggs-metrics-geobounds]]
==== Cardinality Aggregation
Here is how you can use
{ref}/search-aggregations-metrics-geobounds-aggregation.html[Geo Bounds Aggregation]
with Java API.
===== Prepare aggregation request
Here is an example on how to create the aggregation request:
[source,java]
--------------------------------------------------
GeoBoundsBuilder aggregation =
AggregationBuilders
.geoBounds("agg")
.field("address.location")
.wrapLongitude(true);
--------------------------------------------------
===== Use aggregation response
Import Aggregation definition classes:
[source,java]
--------------------------------------------------
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBounds;
--------------------------------------------------
[source,java]
--------------------------------------------------
// sr is here your SearchResponse object
GeoBounds 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]
--------------------------------------------------