Hi I am new to Elastic search. I want to show distance in result while using "_search" where "location" field is of type : geopoint; I found we can use script_fields but this is not working.
To mention : I am using 6.1 ES version.
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "200km",
"location" : {
"lat" : 28.6139,
"lon" : 77.209
}
}
}
}
},
"script_fields" : {
"distance" : {
"lang": "painless",
"params" : {
"lat" : 47.1,
"lon" : 8.1
},
"script" : "doc['location'].DistanceInKm(lat,lon)"
}
}
}
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "Unknown key for a VALUE_STRING in [lang].",
"line": 20,
"col": 18
}
],
"type": "parsing_exception",
"reason": "Unknown key for a VALUE_STRING in [lang].",
"line": 20,
"col": 18
},
"status": 400
}