Time Decay + Distance Decay Algorithm 🤔

hey there,
I’m attempting to use Algolia to construct a feed since I like the robust GEO search features you guys have…

The question I have is if it’s possible to construct a query with a multi variable decay factor (time + distance away)

If its not possible, I will likely have to construct a hybrid solution between Algolia and Getstream to make this work correctly.

1 Like

Hello @arpowers,

Thanks for your interest in Algolia!

It may be possible or not depending on what you are trying to achieve:

  • Geo search ordered by distance from a given location (explicitly specified or based on the IP address) is supported out of the box.
  • Custom ranking makes it possible to order records by recency, provided that they contain a timestamp of some sort in one of their attributes.

The trick is combining both: Algolia uses a tie-breaking algotihm, which means that hits will be sorted either first by distance, then time, or the opposite, depending on your ranking formula.

Combining both into a “fuzzy” criterion is not possible out of the box. You can however come to a similar result by fine-tuning the geo search’s precision using the aroundPrecision parameter. By default it is set to 1 meter, but you can increase it to group hits by range of distance. Hits in the same range will rank equally with regard to the distance, allowing them to be sorted by recency.

Depending on your use case, this mechanism could even be better than a fuzzy score, because it will be more predictable: easier to understand, easier to debug, easier to fine tune… :slight_smile:

Does that make sense? Could you elaborate on your use case?

3 Likes