Custom ranking boundaries

Hello, I’m working on Algolia integrated with as a data source, and currently exploring possible options and limits of the custom rank indices to enhance the UX of our App.

First question

  • Is is possible to define ranking attributes with weights? For instance; I have an offer list,
  • Rank by distance 50%
  • Discount value 20%
  • Views count 20%
  • Random 10%

Is that possible?

Second question

Is there a way to do a lot more advanced formulas, where we have four attributes for ranking, each attribute requires a sub-formula to calculate it, then the four outputs combined would form a final rank for the offer itself?

It’s like nested formulas, with weighting, on four (or x) dimensions.

Hi @mohamed1!

First question: You can’t specify specific weights, but you can only rank the attributes in order or importance. In your case, you could create a custom ranking that includes four fields: distance, discount, views and a random. For distance, discount and views, you would round each number down to 100 or 1000 (or more depending on your data) so that numbers that are roughly equal are considered as ties. Effectively, this lets you control how important each attribute is, while avoiding skew from very high attribute values (e.g. the views count should only count for 20% of the ranking, but the object has 10x more views than others, that criteria alone can make it more relevant than it should be). This is a different way to think about ranking than percentages or boosts but we find that it works well in most cases, with the upside that it’s more usually more predictable.

Second question: You can’t do that on the Algolia side, but you can perform that calculation, put it into an attribute, and then add it to the custom ranking.

Hello @dzello, thanks a lot for your answer, this (kind of) helps :slight_smile:

So you guys don’t have support for serendipity? We want to achieve serendipity (whether with some logic/formulas behind it, or not), and it seems that the custom ranking now works only as sorting then breaking ties.


We love serendipity finding a new restaurant or running into an old friend, just not for relevance :slight_smile:

The user wants predictability from a search, if there is too much randomness or it’s hard to understand why certain results are shown, that can get very frustrating. So we usually tell people to be careful when introducing any complex math - the intention is good but the outcome for the user can be bad and trying to fix/tune the formula without making guesses is a challenge.

You can still add a randomness factor at indexing time to break ties where there is truly not another signal. Depending on how often you re-index, you could change the value to make sure you’re getting some variation.

Nice whitepaper on surprise metrics here:

AFAIK, Algolia does not track search activity to the level of a user profile, which you’d need to promote serendipitous content.

They do take a userToken in their API, but it only seems to be there to avoid unintended rate-limiting.

The market for good basic (non-personalized) search is so huge, I don’t really see Algolia chasing that rabbit for a long time. (Maybe @dzello has more insight.)

Curious to know more about what ended up working for you!


Algolia does have personalization capabilities today, you can see the documentation here:

But I would say we do agree that for many searches in sites and apps today, even without personalization they can benefit greatly from more traditional improvements in relevance (textual relevance, custom ranking).