Geo distance query order by distance


(Michael) #1

I can search geo point that within distance raidus (e.g. < 10 km) with Geo Distance Query(https://www.elastic.co/guide/en/elasticsearch/reference/6.5/query-dsl-geo-distance-query.html#query-dsl-geo-distance-query).

I want to do 1 step further by sorting the results by shortest distance first. Can Elastic Search do that?

E.g. Place 1 is 5km from my loc, Place 2 is 7km from my loc. Geo Distance Query within 10km return both Place 1 and Place 2 , however, Place 1 should have higher score than Place 2.


(Ignacio Vera) #2

Here is the documentation how to sort by distance:

https://www.elastic.co/guide/en/elasticsearch/reference/6.5/search-request-sort.html#geo-sorting

Is that enough for you?