geobounds-aggregation.asciidoc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. [[search-aggregations-metrics-geobounds-aggregation]]
  2. === Geo Bounds Aggregation
  3. added[1.3.0]
  4. A metric aggregation that computes the bounding box containing all geo_point values for a field.
  5. .Experimental!
  6. [IMPORTANT]
  7. =====
  8. This feature is marked as experimental, and may be subject to change in the
  9. future. If you use this feature, please let us know your experience with it!
  10. =====
  11. Example:
  12. [source,js]
  13. --------------------------------------------------
  14. {
  15. "query" : {
  16. "match" : { "business_type" : "shop" }
  17. },
  18. "aggs" : {
  19. "viewport" : {
  20. "geo_bounds" : {
  21. "field" : "location" <1>
  22. "wrap_longitude" : "true" <2>
  23. }
  24. }
  25. }
  26. }
  27. --------------------------------------------------
  28. <1> The `geo_bounds` aggregation specifies the field to use to obtain the bounds
  29. <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`
  30. The above aggregation demonstrates how one would compute the bounding box of the location field for all documents with a business type of shop
  31. The response for the above aggregation:
  32. [source,js]
  33. --------------------------------------------------
  34. {
  35. ...
  36. "aggregations": {
  37. "viewport": {
  38. "bounds": {
  39. "top_left": {
  40. "lat": 80.45,
  41. "lon": -160.22
  42. },
  43. "bottom_right": {
  44. "lat": 40.65,
  45. "lon": 42.57
  46. }
  47. }
  48. }
  49. }
  50. }
  51. --------------------------------------------------