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
source to share