Geo Ranking Precision
Precision (via the search query parameter
aroundPrecision) is used to group results that have more or less the same distance from a central point.
Algolia’s default precision is 1 meter. However, a 1-meter difference might not be significant; maybe only intervals of 200 meters make sense. By creating 200-meter intervals, you rank all records that fall within that interval the same. They are of course ranked higher than all records between 200 and 400.
To be precise, if you set
aroundPrecision to 200, you’ll have the following search results:
- Group of results in the 0-200 meters range will be the best ranked (ranked equally)
- Group of results in the 200-400 meters range will be ranked a bit lower
- Group of results in the 400-600 meters range will be ranked even lower
Another example is when a user is looking for nearby recommended restaurants. The goal is to display results that are a good mix of nearby and highly rated restaurants.
Let’s say there are 2 restaurants within 200 meters from the user’s location:
- restaurant A with a 5 star rating and distance of 150 meters (farther)
- restaurant B with a 3 star rating and distance of 100 meters (closer)
If we are only sorting by geo distance, restaurant B will be ranked higher since it is closer to the user.
But by setting
aroundPrecision to 200, restaurant A and B will be ranked equally: the distances of 150 and 100 will be considered equal to 0 (and distances of 250 and 210 will be equal to 200, and so on).
Going further, since the results of A and B are tied under the
Geo criterion, the search engine will examine the other criteria in the ranking formula to further sort the results. Restaurant A will therefore be ranked higher in the result due to its higher rating.