Invalid distance returned by ElasticSearch distanceInKm

I have 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 obtained is incorrect. If the point is close, the distance is more correct, but as it goes further, it becomes more and more incorrect.

It cannot seem that I am wrong.

+3
elasticsearch


source to share


1 answer


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



+8


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics