我尝试在弹性搜索查询中设置距离我的中心位置的最大距离,排序部分没有问题:
{
"query" : {
"match_all" : {}
},
"sort" : [
{
"_geo_distance" : {
"location" : "56,14",
"order" : "asc",
"unit" : "km"
}
}
]
}
然而,当我尝试添加过滤器时,我会得到"[geo_distance] filter does not support [location]"
:
{
"query" : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "200m",
"location" : {
"location" : "56,14"
}
}
}
}
},
"sort" : [
{
"_geo_distance" : {
"location" : "56,14",
"order" : "asc",
"unit" : "km"
}
}
]
}
我做错了什么想法?
答案 0 :(得分:1)
使用此过滤器
"filter" : {
"geo_distance" : {
"distance" : "200m",
"location" : "56,14"
}
}
位置可以是该字段的任何名称,如果您的字段名称是loc或locator,那么查询将是
"filter" : {
"geo_distance" : {
"distance" : "200m",
"loc"/"locator" : "56,14"
}
}