ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Geo Polygon Query(地理多边形查询) 一个查询,允许包含仅在点的多边形内的命中。 这是一个例子:  | `GET ``/_search` `{` `"query"``: {` `"bool"` `: {` `"must"` `: {` `"match_all"` `: {}` `},` `"filter"` `: {` `"geo_polygon"` `: {` `"person.location"` `: {` `"points"` `: [` `{``"lat"` `: 40, ``"lon"` `: -70},` `{``"lat"` `: 30, ``"lon"` `: -80},` `{``"lat"` `: 20, ``"lon"` `: -90}` `]` `}` `}` `}` `}` `}` `}` | ### Query Options(查询选项)  | Option(选项) | Description(描述) | | --- | --- | | `_name(名称)` | 可选名称字段来标识过滤器 | | `ignore_malformed(忽略格式错误)` | ~~[5.0.0]~~ 设置为** true** 以接受无效纬度或经度的地理点(默认值为假)。 | | `validation_method(验证方法)` | 设置为** IGNORE_MALFORMED** 以接受无效纬度或经度的地理点,**COERCE **尝试推断正确的纬度或经度,或 **STRICT**(默认为 **STRICT**)。 | ### Allowed Formats(允许格式) ### Lat Long as Array(Lat Long 作为阵列) 格式在** [lon,lat]** 中,注意,这里的 **lon / lat** 的顺序是为了符合 **[GeoJSON](http://geojson.org/). ** | `GET ``/_search` `{` `"query"``: {` `"bool"` `: {` `"must"` `: {` `"match_all"` `: {}` `},` `"filter"` `: {` `"geo_polygon"` `: {` `"person.location"` `: {` `"points"` `: [` `[-70, 40],` `[-80, 30],` `[-90, 20]` `]` `}` `}` `}` `}` `}` `}` | ### Lat Lon as String(Lat Lon 作为字符串)  格式在 **lat,lon。  ** | `GET ``/_search` `{` `"query"``: {` `"bool"` `: {` `"must"` `: {` `"match_all"` `: {}` `},` `"filter"` `: {` `"geo_polygon"` `: {` `"person.location"` `: {` `"points"` `: [` `"40, -70"``,` `"30, -80"``,` `"20, -90"` `]` `}` `}` `}` `}` `}` `}` | ### Geohash(地理散列)  | `GET ``/_search` `{` `"query"``: {` `"bool"` `: {` `"must"` `: {` `"match_all"` `: {}` `},` `"filter"` `: {` `"geo_polygon"` `: {` `"person.location"` `: {` `"points"` `: [` `"drn5x1g8cu2y"``,` `"30, -80"``,` `"20, -90"` `]` `}` `}` `}` `}` `}` `}` | ### geo_point Type(geo_point类型) 该查询需要在相关字段上设置** [`geo_point`](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/geo-point.html "Geo-point datatype")** 类型。 ### Ignore Unmapped(忽略未映射) 当设置为** true** 时,**ignore_unmapped** 选项将忽略未映射字段,并且将不会匹配此查询的任何文档。 当查询可能具有不同映射的多个索引时,这可能很有用。 当设置为** false**(默认值)时,如果字段未映射,则查询将抛出异常。