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