Referring to the ES documentation, we can sort on the base of geolocation if lat and lon are both in the same geotype field.
{
"sort" : [
{
"_geo_distance" : {
"pin.location" : [-70, 40],
"order" : "asc",
"unit" : "km",
"mode" : "min",
"distance_type" : "arc",
"ignore_unmapped": true
}
}
],
"query" : {
"term" : { "user" : "kimchy" }
}
}
In my case, I have the location in separate float fields for both latitude and longitude. How can I sort on geo-distance if I can't change my schema?