Personalization - Enterprise only

ENTERPRISE only feature: This guide goes over features that are only accessible for our enterprise plans
Table of content


Algolia is amazing at building a search which delivers relevant results in an immersive experience. Once you’ve refined your Algolia implementation and are happy with the quality of the results, you can go a step beyond: personalizing the search results.

Personalization means being able to influence the ranking of the search results based on rules related to the individual user currently performing the search. A few examples to illustrate this idea:

  • On Netflix, retrieve first the movies that I added to my watch list
  • On Asana, retrieve first the tasks that are assigned to me
  • On Amazon, retrieve first products that are in my usual price-range, or the ones from brands that I bought from before

This guide explains how to use two features called optional filters and filters scoring to achieve this type of personalized ranking strategies.

Given the high CPU requirements, personalization is restricted to Enterprise plans running on dedicated servers.

Live demo

Personalization demo

We built a demo showcasing personalization on a search for movies.

We defined 4 user profiles with different types of preferences:

  • Julien likes Documentaries
  • Nicolas likes Drama and Matt Damon
  • Sylvain has movies in his watch-list
  • Gaetan likes Action and has a watch-list

Query parameters enabling personalization

Optional filters

You are probably already familiar with the filters search parameter. We will now use a new search parameter: optionalFilters.

The optional filters have a similar behavior to the regular ones, except that they don’t exclude the results that don’t match the filter, they just rank them lower (see the next section on scoring).

Optional Filters can be applied on any attribute declared in attributesForFaceting (like regular filters). For example, if you have declared attributesForFaceting=["brand"], and you do the query:"phone", { optionalFilters: ["brand:samsung"] });
/* Will rank results in this order:
1. Phones from the brand Samsung
2. Other phones */

You shouldn’t use more than one optional filter on searches matching more than 100k results, more in the Limitations section.

Filters scoring

Optional filters allow you to create two buckets of results: the ones that match the optional filter, and the others, and impact the ranking of the results depending on the bucket they are in.

Filters scoring is a way to create more than two buckets by specifying different scores for different filters.

For example, if you want to give a bonus in the ranking to the results having the brands Samsung or Apple, but return the ones with Apple first, you can specify it by using this syntax:"phone", { optionalFilters: ["brand:apple<score=2>", "brand:samsung<score=1>"] });
/* Will rank results in this order:
1. Phones from the brand Apple (score = 2)
2. Phones from the brand Samsung (score = 1)
3. Other phones (score = 0) */

The filters scoring can be used on optionalFilters, but also on regular filters or facetFilters.

Filters scoring shouldn’t be used on searches matching more than 100k records, more in the Limitations section.

How personalization impacts the ranking

Both the optional filters and the filters scoring rely on a dedicated rule in the ranking formula, called filters.

By default, this rule is placed in 4th position, after typo, geo, and words, which is a good choice for the majority of the use cases.

How the scores are calculated

The calculation of the total score (which will be used in the filters rule of the Ranking Formula) follows three rules:

  • When no score is specified, it defaults to 1
  • When you specify scores on multiple filters, the global score is equal to the sum of the per-filter scores matching
  • When you have an OR condition between filters, only the filter with the highest matching score will be taken into account, even if there are multiple filters matching

Let’s look at two examples:

optionalFilters = ["brand:Apple", "brand:Samsung<score=2>"]
/* Will rank results in this order:
1. Samsung (score = 2)
2. Apple (score = 1)
3. other brands (score = 0) */

optionalFilters = ["brand:Apple", "brand:Samsung<score=2>", "users:user42<score=3>"]
/* Will rank results in this order:
1. Samsung and user42 (score = 5)
2. Apple and user42 (score = 4)
3. other brands and user42 (score = 3)
4. Samsung, no match on user42 (score = 2)
5. Apple, no match on user42 (score = 1)
6. other results (score = 0) */

To add/remove the user IDs to your records, you don’t need to send the complete list of IDs each time. You can use our Add, AddUnique, or Remove partial update methods.


Size of the dataset

If you’re using only one optional filter, you can use it on any size of datasets. But you shouldn’t use these features with more than one filter on searches matching more than 100k results. Doing so would impact heavily the performance, and provide unreliable and non-exhaustive results.

Number of filters applied

You should minimize the number of filters used as much as possible. You should never go above 10 filters applied on the same query.

Optional filters on empty query

For performance reasons, optional filters are transformed into their regular filter equivalent on an empty query (no other search parameters).