geobounds-aggregation.asciidoc 1.6 KB

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