# 地理边界聚合(Geo Bounds Aggregation)

地理边界聚合是一个度量聚合，为一个字段计算包含所有地点值的边界框。

例如：

```
{
    "query" : {
        "match" : { "business_type" : "shop" }
    },
    "aggs" : {
        "viewport" : {
            "geo_bounds" : {
                "field" : "location",  # 1
                "wrap_longitude" : true   # 2
            } 
        } 
    } 
}
```

| 1 | 地理边界聚合指定一个字段用来获得边界。                                  |
| - | ---------------------------------------------------- |
| 2 | wrap\_longitude是一个可选参数，指定边界框是否允许与国际日期变更线重叠，默认值是true。 |

上面的聚合实例表示查询所有业务类型为商店的文档，并且根据文档中的位置字段计算出边界框。

上面聚合语句的返回值为：

```
{
    ...

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xiaoxiami.gitbook.io/elasticsearch/ji-chu/36aggregationsju-he-fen-679029/liang-du-ju-540828-metric-aggregations/di-li-bian-jie-ju-540828-geobounds-aggregation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
