Geo Distance calculation using script fields in v5.0.1 [reason] Unable to find dynamic method [distanceInKm]


(Patlola) #1
{
  "script_fields": {
    "distance": {
      "script": {
        "inline": "doc['location'].distanceInKm(12.898365,77.594359)"
      }
    }
  }
}

mappings
"location": {
"type": "geo_point"
}
got the following error as unable to find dynamic method distanceInKm

"reason": {
	"type": "script_exception",
	"reason": "runtime error",
	"caused_by": {
		"type": "illegal_argument_exception",
		"reason": "Unable to find dynamic method [distanceInKm] with [2] arguments for class [org.elasticsearch.index.fielddata.ScriptDocValues.GeoPoints]."
	},
	"script_stack": ["doc['location'].distanceInKm(12.898365,77.594359)", " ^---- HERE"],
	"script": "doc['location'].distanceInKm(12.898365,77.594359)",
	"lang": "painless"
}

tried reading all the docs unable to resolve this. hope the folks here will help me solve this.
I was abe to find distance using sort functionality but distanceInKM is not working!
is it a bug or my query is wrong ?


Finding distance between Geo Points
(Patlola) #2

@dadoonet can you please help on this ?


(Patlola) #3

distanceInKm is deprecated in V5.0 version using https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_50_scripting.html#_geopoint_scripts


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.