Hello ,
I would like to get the results where coordinates are less than 15 km from this point for example: [35.3,-2.5] but I have this error : no [query] registered for [station_location]
my request is :

here the response :

the index mapping :
...
here on document example :

I am not sure I understand what your question or problem is. Could you please clarify?
I think the query is wrong and Elasticsearch is looking for a query called station_location. Instead you need to place the query geo_distance:
"filter" : {
"geo_distance" : {
"distance" : "200km",
"station_location" : {
"lat" : 35.5,
"lon" : -2.5
}
}
}
Thank you very much , it works well,
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "10500m",
"station_location" : "35.5,-2.5"
}
}
}
}
}
one last question how to get with the results the distance?
To get the distance of the document in km:
{
"_source": "*",
"script_fields": {
"distance" : {
"script" : {
"source": "doc['station_location'].arcDistance(params.lat,params.lon) * 0.001",
"params": {
"lat": 2.27,
"lon": 50.3
}
}
}
},
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "10500m",
"station_location" : "35.5,-2.5"
}
}
}
}