ElasticSearch distanceInKm返回错误的距离 [英] Wrong distance returned by ElasticSearch distanceInKm

查看:746
本文介绍了ElasticSearch distanceInKm返回错误的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一个返回距离的脚本字段,如弹性搜索结果中的返回距离

I've implemented a script field that returns distance like here Return distance in elasticsearch results?

Ruby:

{
  script_fields: {
    distance: {
      script: "doc['#{source_field}'].distanceInKm(#{lat}, #{lng})"
    }
  }
}

然而返回的距离是不正确的。如果点靠近,距离更正确,但随着距离越来越远,它的越来越不正确。

However the distance returned isn't correct. If the point is close, the distance is more correct but as it gets further away it gets more and more incorrect.

似乎无法弄清楚我是什么做错了。

Can't seem to figure out what I'm doing wrong.

推荐答案

distanceInKm()将距离计算在飞机上的点数,这很快但不是很准确。尝试使用arcDistanceInKm()。

distanceInKm() calculates distance as points on a plane, which is fast but not very accurate. Try using arcDistanceInKm() instead.

这篇关于ElasticSearch distanceInKm返回错误的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆