Pass back distance on geosearch

We have a search (using ReactInstantSearch) which incorporates distance from a geolocation in its results and displays items on a map. We want to display on each item how far away it is from the user, i.e. ‘200m from you’ or ‘2km from you’.

Is there any way to configure Algolia so that the results we receive back from the search includes the distance that each item is away from the geolocation?

Hello @owen,

Yes, there is! You just need to enable detailed ranking information via getRankingInfo. This will return inside each hit a _rankingInfo object containing (among others) the distance from the object to the searched location. (In case the hit has many locations, the best matching, i.e. the shortest distance, is returned.)

Awesome, thanks Clement. Looks like exactly what we were looking for.