2017-06-02 101 views
1

我需要在使用地理距离查询的弹性搜索中获得与搜索到的坐标的距离。我想这弹性搜索中的地理距离查询中的返回距离5.x

curl -XGET 'http://127.0.0.1:9200/branch-master/master/_search?pretty=1' -d ' 
{ 
    "script_fields" : { 
     "distance" : { 
     "params" : { 
      "lat" : 18.00, 
      "lon" : 72.00 
     }, 
     "script" : "doc[\u0027location\u0027].distanceInKm(lat,lon)" 
     } 
    } 
} 
' 

这是从Return distance in elasticsearch results?

了但是这给了我的错误“而将start_object [PARAMS]未知的密钥”。我无法理解这是什么。以上解决方案似乎适用于相当老的ES版本。我正在使用ES 5.1。在手册中我找不到地理距离查询的相关解决方案。有人可以帮我吗?

回答