Elasticsearch 7.4使用MultiPoint执行geo_shape查询报错问题咨询
问题原因及解决方案
问题根源
这是Elasticsearch 7.4的版本限制导致的。在7.4版本中,geo_shape查询仅支持有限的几何类型作为查询条件,MultiPoint不在支持范围内,因此会抛出Field [geometry] does not support multipoint queries的错误。
替代实现方案
如果需要查询与多个点相交的要素,可以通过bool查询的should子句,将多个Point类型的geo_shape查询组合起来,只要要素与任意一个点相交就会被匹配。示例语句如下:
GET xxxx/_search { "query": { "bool": { "should": [ { "geo_shape": { "geometry": { "shape": { "type": "Point", "coordinates": [-90, 40] }, "relation": "intersects" } } }, { "geo_shape": { "geometry": { "shape": { "type": "Point", "coordinates": [-80, 30] }, "relation": "intersects" } } } ] } } }
版本升级说明
如果长期需要使用MultiPoint等复杂几何类型作为查询条件,建议升级到Elasticsearch 7.10及以上版本——后续版本扩展了geo_shape查询支持的几何类型,包含MultiPoint、MultiLineString等。
内容的提问来源于stack exchange,提问作者Roman
相关产品推荐
相关产品推荐

