0
在elasticsearch中,我想用geo_distance过滤器查询多个索引。多索引上的Elasticsearch geo_distance过滤器
问题是一个索引具有geo_point映射,另一个没有geo_point映射。
如果我使用纬度和经度查询,我只会得到具有geo_point映射的索引的结果。对于其他索引我得到未能找到geo_point字段异常。
如何从两个索引中获得结果?
以下是我的查询。
{
"query":{
"filtered":{
"query":{
"bool":{
"should":{
"match_all":{
}
}
}
},
"filter":{
"bool":{
"should":[
{
"bool":{
"must":[
{
"geo_distance":{
"distance":"50km",
"location":{
"lat":22.5705741,
"lon":88.4355427
}
}
}
]
}
}
]
}
}
}
},
"sort":[
{
"_geo_distance":{
"location":{
"lat":22.5705741,
"lon":88.4355427
},
"order":"asc",
"unit":"km"
}
}
],
"size":30,
"from":0
}
我使用elasticsearch优化版本0.90.12
很明显嘛,如果你的第二个指标没有geo_point场,使用geo_distance过滤器查询它会很困难,不是吗?你可以尝试的一件事是使用['type' filter](https://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-type-filter.html)并结合' geo_distance'过滤器中的'type'类型具有geo_point。但是,如果geo_distance是唯一的过滤器,我看不到从没有任何geo-ish信息的另一个索引检索结果的要点。 – Val
@Val还有一个匹配查询以及geo_distance过滤器。我会尝试一下类型过滤器,并让你知道它是怎么回事。 – tungri
@Val你可以给一个在解释场景中使用类型过滤器的例子吗?即对一个索引具有geo_point字段且在另一个索引中丢失的索引进行geo_distance搜索。谢谢 – tungri