【发布时间】:2013-04-13 08:49:07
【问题描述】:
假设我们在 ElasticSearch 索引中有一堆文档。每个文档都有多个位置在一个数组中,像这样:
{
"name": "foobar",
"locations": [
{
"lat": 40.708519,
"lon": -74.003212
},
{
"lat": 39.752609,
"lon": -104.998100
},
{
"lat": 51.506321,
"lon": -0.127140
}
]
}
根据ElasticSearch reference guide
geo_distance过滤器可以处理多个位置/点 每个文件。一旦单个位置/点与过滤器匹配, 文档将包含在过滤器中。
那么,是否可以创建一个地理距离过滤器来检查数组中的所有位置?
不幸的是,这似乎不起作用:
{
"filter": {
"geo_distance": {
"distance": "100 km",
"locations": "40, -105"
}
}
}
抛出“QueryParsingException[[myIndex] failed to find geo_point field [locations]”,因为locations 不是单个geo_point,而是geo_points 的数组。
【问题讨论】:
标签: elasticsearch