geobounds-aggregation.asciidoc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. [[search-aggregations-metrics-geobounds-aggregation]]
  2. === Geo Bounds Aggregation
  3. experimental[]
  4. A metric aggregation that computes the bounding box containing all geo_point values for a field.
  5. Example:
  6. [source,js]
  7. --------------------------------------------------
  8. {
  9. "query" : {
  10. "match" : { "business_type" : "shop" }
  11. },
  12. "aggs" : {
  13. "viewport" : {
  14. "geo_bounds" : {
  15. "field" : "location", <1>
  16. "wrap_longitude" : true <2>
  17. }
  18. }
  19. }
  20. }
  21. --------------------------------------------------
  22. <1> The `geo_bounds` aggregation specifies the field to use to obtain the bounds
  23. <2> `wrap_longitude` is an optional parameter which specifies whether the bounding box should be allowed to overlap the international date line. The default value is `true`
  24. The above aggregation demonstrates how one would compute the bounding box of the location field for all documents with a business type of shop
  25. The response for the above aggregation:
  26. [source,js]
  27. --------------------------------------------------
  28. {
  29. ...
  30. "aggregations": {
  31. "viewport": {
  32. "bounds": {
  33. "top_left": {
  34. "lat": 80.45,
  35. "lon": -160.22
  36. },
  37. "bottom_right": {
  38. "lat": 40.65,
  39. "lon": 42.57
  40. }
  41. }
  42. }
  43. }
  44. }
  45. --------------------------------------------------