How to calculate Distance between Geolocation?

Hello, I am implementing a geolocation search.

Is there a way for AppSearch to calculate the distance between locations?

I know I can do this search. but is it possible that the result of the consultation shows the distance between the places?

Search Example:

"filters": {
    "location": {
      "center": "37.386483, -122.083842",
      "distance": 300,
      "unit": "km"
    }
  }

Answer Example.

[
   {
      "restaurant": "Restaurant 1",
      "distance": "3km"
   },
   {
      "restaurant": "Restaurant 2",
      "distance": "10km"
   },
   {
      "restaurant": "Restaurant 3",
      "distance": "14km"
   }
]

Hey @murilovictor, is this something that you can do yourself? Since you have the "center" and a location field on each document, you should be able to calculate this.

The one thing I am not sure of that you may want is the ability to sort based on that distance.

1 Like

Elasticsearch has Geo Sorting, which is not currently available in App Search: https://www.elastic.co/guide/en/elasticsearch/reference/6.5/search-request-sort.html#geo-sorting

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.