[英]Elasticsearch geo-location search not returning results for miles unit
im using elasticsearch to return business near a users location. 即时通讯使用Elasticsearch在用户位置附近返回业务。
If i search with a distance unit of kilometer 'km' i get expected results but if i use miles 'm' it return 0 hits 如果我以公里“ km”的距离单位进行搜索,则会得到预期的结果,但是如果我使用英里“ m”,它将返回0次命中
example of km request with hits 匹配请求的公里请求示例
{
"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 miles so this query should return the same number of results as above but returns 0 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
}
}
}
}
}
}
Any ideas why this might be? 任何想法为什么会这样?
You simply need to use the correct distance unit : m
is for meters, and for miles you need to use mi
您只需要使用正确的距离单位 : m
是米,而英里则需要mi
{
"sort" : [
{
"_geo_distance" : {
"location" : {
"lon": -0.11454850000000001,
"lat": 51.4911665
},
"order" : "asc",
"unit" : "mi" <--- here
}
}
],
"query": {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "1mi", <--- here
"location" : {
"lon": -0.11454850000000001,
"lat": 51.4911665
}
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.