【发布时间】:2016-02-05 23:18:43
【问题描述】:
我的文档在包含位置的弹性搜索中。它们在文档中包含一个名为 location 的字段,其映射为:"location": {"type": "geo_shape"}。我在文档中索引了城市和国家/地区。
在城市类型文档中(由字段"location_type": "city" 标识),位置字段如下所示:"location": {"type": "Point", "coordinates": [12.343, 43.454]}。
在国家类型文档中,(由字段"location_type": "country" 标识),位置字段如下所示:"location": {"type": "MultiPolygon", "coordinates": [[12.343, 43.454], [12.23, 34.231]...]}。
我的问题是,我可以像这样运行 geo_distance 过滤器查询吗:
{
"query": {
"filtered": {
"query": {
"term": {
"location_type": {
"value": "city"
}
}
},
"filter": {
"geo_distance": {
"distance": 100,
"distance_unit": "km",
"location.coordinates": {
"lat": 40.73,
"lon": -74.1
}
}
}
}
}
}
这给了我一个错误,说:nested: QueryParsingException failed to find geo_point field [location.coordinates]
我怎样才能使这个查询工作?
【问题讨论】: