【发布时间】:2017-03-01 03:35:11
【问题描述】:
我使用弹性搜索返回用户位置附近的业务。
如果我使用公里“km”的距离单位进行搜索,我会得到预期的结果,但如果我使用英里“m”,它会返回 0 次点击
带有命中的公里请求示例
{
"sort" : [
{
"_geo_distance" : {
"location" : {
"lon": -0.11454850000000001,
"lat": 51.4911665
},
"order" : "asc",
"unit" : "km"
}
}
],
"query": {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "1km",
"location" : {
"lon": -0.11454850000000001,
"lat": 51.4911665
}
}
}
}
}
}
1km = 0.6 英里,因此此查询应返回与上述相同数量的结果,但返回 0
{
"sort" : [
{
"_geo_distance" : {
"location" : {
"lon": -0.11454850000000001,
"lat": 51.4911665
},
"order" : "asc",
"unit" : "m"
}
}
],
"query": {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "1m",
"location" : {
"lon": -0.11454850000000001,
"lat": 51.4911665
}
}
}
}
}
}
任何想法为什么会这样?
【问题讨论】:
-
m是米,英里是mi(more info about distance units) -
你是正确的,如果你把它放在一个答案中,我会标记为接受
标签: php search elasticsearch geolocation location-services