I am currently working on creating a custom script in Java for Elasticsearch to assist with scoring. If I was using mvel I could just say
doc['field_name'].distance(lat, lon)
In java there seems to be no (seemingly available) distance functions that I can run against a field in the document. This is ok, I guess, because I could use the Haversine distance formula if I had it. However, if there was something built into the Elasticsearch libraries then I would rather use that.
Translated to the native script, your mvel statement would look like this:
It’s also possible to retrieve lists of latitudes and longitudes as arrays using
getLats()andgetLons()method and calculate the distances using