Yeah, it's one of these gotchas that many people run into. When you specify
location as an array, it follows GeoJson format [lon, lat], instead of lat,
lon. So, if you will flip the numbers in _geo_distance sort location, it
will work as expected:
On Tuesday, April 24, 2012 4:19:53 PM UTC-4, Kaspars Sprogis wrote:
Since in my test case all returned "sort" fields were almost identical
(event if distance is different) i decided sort key is something different,
some value of inner calculations.
So i think there is a bug somewhere with geo-search, so i reported whole
test case to github issues
Because if you look at my test case: https://gist.github.com/2483009
You will see that returned "sort" values are almost identical and also
returned sort order is wrong...
Thanks, it is good to know "sort" actually should return distance, let's
hope there is some explanation why problems in my test case appears.
On Tuesday, April 24, 2012 11:01:23 PM UTC+3, Igor Motov wrote:
Take a look at this example: https://gist.github.com/2483149
The value in the "sort" field is the distance:
"sort" : [ 114.81801790248922 ]
On Tuesday, April 24, 2012 2:55:58 PM UTC-4, Kaspars Sprogis wrote:
I look at that posting already, and i am already sorting by
_geo_distance but no actual distance value is returned (using latest 0.9.2)
Then only in once place somewhere on stackoverflow i found that we need
to use script_fields to get distance to the results and i am wondering why
in many places it is mentioned that distance should be in results if you
are sorting by _geo_distance if it is not?! Maybe i am doing something
wrong, but i tested thousand times.
Only way i could get distance is like this:
"script": "doc['location'].arcDistanceInKm(lat, lon)"
On Tuesday, April 24, 2012 9:50:07 PM UTC+3, Peter Schröder wrote:
have a look at this posting
Am Dienstag, 24. April 2012 19:51:59 UTC+2 schrieb Kaspars Sprogis:
I am also interested in this. Can anyone help? Thanks
On Wednesday, September 7, 2011 6:58:47 PM UTC+3, Matthias Nothhaft
I'm trying to use elasticsearch for geo location search. It works
fine so using a filtered query and the geo_distance filter. What I miss in
the search result is the distance between "my location" and each of the
results. Is it possible somehow to add the distance to the result? Can
someone give me an example or point me to some docs how to make it?