elasticsearch
elasticsearch copied to clipboard
geo sort
Hi,
I am wondering how can I use sort by distance? if I set parameter "sort" make it like:
{..., "sort"=>array("name", "id")}
it works ok, but I have a location field which is mapped as "geo_point" but when I add in that array "location" the results disappear, and I guess there is an error underneath (meaning the response from the ES, not your lib)?
Any ideas?
Thank you
I had the same problem. This is what I used:
'sort' => array(
array(
'_geo_distance' => array(
'location' => array(
'lat' => $this->latitude,
'lon' => $this->longitude,
),
'order' => 'asc',
'unit' => 'km'
),
),
),