summaryrefslogtreecommitdiff
path: root/docs/reference/search/aggregations/metrics/geobounds-aggregation.asciidoc
blob: ade59477ee3720b25b04e1b375ca56cae22108e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[[search-aggregations-metrics-geobounds-aggregation]]
=== Geo Bounds Aggregation

A metric aggregation that computes the bounding box containing all geo_point values for a field.


Example:

[source,js]
--------------------------------------------------
{
    "query" : {
        "match" : { "business_type" : "shop" }
    },
    "aggs" : {
        "viewport" : {
            "geo_bounds" : {
                "field" : "location", <1>
                "wrap_longitude" : true <2>
            }
        }
    }
}
--------------------------------------------------

<1> The `geo_bounds` aggregation specifies the field to use to obtain the bounds
<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`

The above aggregation demonstrates how one would compute the bounding box of the location field for all documents with a business type of shop

The response for the above aggregation:

[source,js]
--------------------------------------------------
{
    ...

    "aggregations": {
        "viewport": {
            "bounds": {
                "top_left": {
                    "lat": 80.45,
                    "lon": -160.22
                },
                "bottom_right": {
                    "lat": 40.65,
                    "lon": 42.57
                }
            }
        }
    }
}
--------------------------------------------------