One of Algolia’s primary design goals is always to yield the most relevant results, with a predictable, customizable, and easy to understand ranking formula. Randomizing results defeats that purpose, which is is why there’s no built-in way to do it. There are, however, a few possible solutions:
- Periodically shuffle results. You can add an attribute with a random integer value to all your records. Then, you can use this attribute as part of the custom ranking in your ranking formula. The results are still predictable in the sense that all users get identical results for the same query. Still, you may periodically change the random value and reindex the objects, thus changing the order of the results. This is useful if you want to implement a random daily selection of items, for example.
- Randomize results on the client-side. In this case, you shuffle results after Algolia returns them. When doing so, you may want to retrieve additional ranking information to ensure you don’t break the relevance. For instance, you should only shuffle groups of records that rank identically.
Article is closed for comments.