Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 弹性搜索5.x中地理距离查询中的返回距离_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Geolocation_Distance - Fatal编程技术网 elasticsearch 弹性搜索5.x中地理距离查询中的返回距离,elasticsearch,geolocation,distance,elasticsearch,Geolocation,Distance" /> elasticsearch 弹性搜索5.x中地理距离查询中的返回距离,elasticsearch,geolocation,distance,elasticsearch,Geolocation,Distance" />

elasticsearch 弹性搜索5.x中地理距离查询中的返回距离

elasticsearch 弹性搜索5.x中地理距离查询中的返回距离,elasticsearch,geolocation,distance,elasticsearch,Geolocation,Distance,我需要使用地理距离查询从弹性搜索中搜索的坐标中获取距离。我试过这个 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 },

我需要使用地理距离查询从弹性搜索中搜索的坐标中获取距离。我试过这个

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)"
      }
   }
}
'
这是从


但这给了我一个错误“在[params]中的start_对象的未知密钥”。我不明白这是什么。上述解决方案似乎适用于较旧版本的ES。我使用的是ES 5.1。在手册中,我找不到地理距离查询的相关解决方案。有人能帮我吗?

方法
distanceInKm
已被弃用,现在已被删除(5.x)。例如使用
arcdestance
。更多信息请点击此处:

语法有点变化。这在Elasticsearch 5.6中适用

{
    "script_fields": {
        "geo_distance": {
            "script": {
                "params": {
                    "lat": 18.00,
                    "lon": 72.00
                },
                "inline": "doc['location'].arcDistance(params.lat, params.lon)"
            }
        }
    }
}

这是从doc['location']点到参数中的(纬度、经度)的计算距离吗?如果我有两个(lat,lon)对的参数,我如何计算它们的距离?