geobounds-aggregation.asciidoc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. Example:
  5. [source,js]
  6. --------------------------------------------------
  7. {
  8. "query" : {
  9. "match" : { "business_type" : "shop" }
  10. },
  11. "aggs" : {
  12. "viewport" : {
  13. "geo_bounds" : {
  14. "field" : "location", <1>
  15. "wrap_longitude" : true <2>
  16. }
  17. }
  18. }
  19. }
  20. --------------------------------------------------
  21. <1> The `geo_bounds` aggregation specifies the field to use to obtain the bounds
  22. <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`
  23. The above aggregation demonstrates how one would compute the bounding box of the location field for all documents with a business type of shop
  24. The response for the above aggregation:
  25. [source,js]
  26. --------------------------------------------------
  27. {
  28. ...
  29. "aggregations": {
  30. "viewport": {
  31. "bounds": {
  32. "top_left": {
  33. "lat": 80.45,
  34. "lon": -160.22
  35. },
  36. "bottom_right": {
  37. "lat": 40.65,
  38. "lon": 42.57
  39. }
  40. }
  41. }
  42. }
  43. }
  44. --------------------------------------------------