Guides / Algolia AI

The relevance of your search results often changes with time, and it can change fast. Take a drugstore as an example. Users that searched for “mask” before February 2020 (the outbreak of the COVID-19 pandemic) most probably were looking to buy facial masks to take care of their skin. During the pandemic, users were more likely to look for surgical masks.

To address users’ changing expectations, you might have to tweak your results using tools like Rules or optionalFilters. This can become time-consuming because trends come and go fast. A better, more scalable approach is to use Dynamic Re-Ranking.

What is Dynamic Re-Ranking?

Dynamic Re-Ranking is an Algolia feature that uses AI to find trends in your users’ behavior. Based on the query and the position of the result they click or convert, it can improve your relevance by boosting results that are rising in popularity. Dynamic Re-Ranking can also demote results that aren’t relevant to your users in the context of a particular query.

Returning to the drugstore example, Dynamic Re-Ranking detects that people searching for “mask” are often looking for surgical masks instead of face masks and automatically boosts surgical masks in the results. This, in turn, leads to a more relevant search and can result in a higher conversion rate without you having to create Rules or use optionalFilters to tweak relevance.

Only Premium plans can access this feature.

Effect on relevance

While Dynamic Re-Ranking can be a powerful tool in tweaking your relevance, you don’t want it to interfere with the relevance you’ve already set up. For this reason, Dynamic Re-Ranking kicks in after the engine has computed your results’ textual relevance and has applied your custom ranking. If you use Rules to pin or hide specific records, the engine applies them after re-ranking so that they keep working as expected. The engine applies all other Rules before re-ranking. This means re-ranking can override Rules that boost and bury categories.

Re-ranking doesn’t take effect if you enable Personalization and Algolia has enough data to personalize the search. However, re-ranking kicks back in if there’s not enough data to personalize a search for first-time users. The engine doesn’t apply both Personalization and Dynamic Re-Ranking concurrently.

The engine applies the relevance strategies in this order:

  1. Textual ranking criteria
  2. Business relevance (custom ranking)
  3. Personalization (if you’ve enabled it and the engine has enough information to personalize results for a particular user)
  4. Boosting and burying categories with Rules
  5. Dynamic Re-Ranking
  6. Promoting and hiding specific items with Rules

By default, Algolia doesn’t apply re-ranking on empty searches, but you can enable re-ranking for empty searches filtered on a particular facet value.

Simulate Dynamic Re-Ranking

You can simulate re-ranking for any index from the Dynamic Re-Ranking page in the dashboard. As long as you’ve sent some click and conversion events, this screen lets try out any query and see how Dynamic Re-Ranking affects the results (without activating re-ranking on your live index).

Simulating Dynamic Re-Ranking on your indices with the Re-Ranking Simulator

In the simulator, each record has an attractiveness score per query. This score is the number of events this record received last month compared to other records, and it explains why re-ranking boosts one record over another.

Promotion Rules take precedence over Dynamic Re-Ranking. If you use Rules to pin top items for the popular queries, Dynamic Re-Ranking has a limited effect. You can turn off the Rules in the simulator using the Rules toggle to assess the benefits of Dynamic Re-Ranking actions. You can then consider removing these Rules if you’re satisfied with the records that Dynamic Re-Ranking promotes.

Set up Dynamic Re-Ranking

You must set up click or conversion events before using Dynamic Re-Ranking to automatically improve your relevance.

Click and conversion events

To use Dynamic Re-Ranking, you must send Algolia click or conversion events (or both if they differ). Algolia AI uses this data to detect trends in your users’ behavior and re-rank results based on these trends.

Dynamic Re-Ranking refreshes each query’s ranking every 24 hours. Re-Ranking takes the last 30 days into account, meaning it’s based on a sliding window of the most recent analytics data. For a record to be promoted for a given query, Re-Ranking requires it to have at least 20 clicks or two conversions during the 30 days time window. Re-Ranking promotes up to 20 items with the highest scores matching those criteria per query.

Security best practices

To prevent malicious users from manipulating the ranking of your records, Dynamic Re-Ranking uses a distinct userToken per event policy. That means when a userToken sends duplicated events, only one counts for re-ranking purposes. For instance, if the same person clicks on the same record 100 times after the same query, it counts as one click, as long as they’re using the same userToken. If the same userToken clicks on the same record after different searches, they count as separate events.

To prevent users from manually crafting several userTokens, use secured API keys. With secured API keys, you can include the userToken as an embedded parameter when you generate the key on your backend. This lets you give each user a unique key, but they can’t change its userToken.

Dynamic Re-Ranking options

You can configure the following options from the Dynamic Re-Ranking page in the dashboard.

Enable re-ranking on browsing pages

By default, Algolia doesn’t dynamically re-rank empty queries. Setting a Browsing facet re-ranks empty queries that include a facetFilters for that attribute.

For instance, if you use Algolia to populate your website’s category pages by performing an empty query with a category facet, you can set category as a Browsing facet. Re-ranking reorders records in each category based on their popularity.

If you set the root of a nested faceting attribute as a Browsing facet, Re-ranking will reorder all its sub-attributes. For example, if you have an attribute named hierarchicalCategories with several nested levels (like hierarchicalCategories.level0 and hierarchicalCategories.level1), using only hierarchicalCategories as a Browsing facet will re-rank empty queries filtered on hierarchicalCategories.level0 and hierarchicalCategories.level1 as well.

Disable re-ranking for specific records

If you set a Re-Ranking Filter, the Dynamic Re-Ranking only promotes items matching the configured filter.

For instance, if you select instock = true, it prevents Dynamic Re-Ranking from promoting popular items currently out of stock.

Group similar queries

By default, each query is re-ranked independently. The *Group Similar Queries option on the Dynamic Re-Ranking settings page lets you group similar queries which helps with re-ranking less frequent query variations.

Queries are grouped if they share the exact words (in any order).

It’s recommended to set a language for grouping by choosing the appropriate option from the Group Similar Queries drop-down. Setting a language allows Dynamic Re-Ranking to ignore plurals, conjugations, and stop words during the grouping phase.

Re-rank more records per query

You can increase the number of records re-ranked per query from the default of 20 to 100.

Fewer records than the value set here may be re-ranked if Dynamic Re-Ranking doesn’t gather significant traffic on enough records.

Give more weight to recent events

To give more weight to recent events in the ranking computation, you can enable the Event freshness option. If you don’t, an event that happened four weeks ago affects re-ranking the same way as an event that happened yesterday. Enabling event freshness better handles seasonality and shorter search trends.

Once you toggle Event freshness on, the engine recomputes re-ranking so that newer events have more weight than older ones. You don’t have to make any other changes—coding or otherwise.

Use a different events source index

By default, Dynamic Re-Ranking uses the events sent to the re-ranked index. You can use another index as the source for the events by changing the Events source index option.

Enable Dynamic Re-Ranking for production

Before you enable Dynamic Re-Ranking for an index, always A/B test your re-ranking first.

You can enable Re-Ranking on the Dynamic Re-Ranking page in the dashboard. Select the index you want to activate Re-Ranking for, and press the Activate Re-Ranking button.

A/B test Dynamic Re-Ranking

Always use A/B testing to evaluate re-ranking on an index. This way, you can accurately measure re-ranking’s effect on your search. You can create an A/B test for re-ranking directly from the Dynamic Re-Ranking page in the dashboard by clicking the Launch an A/B test button at the top right of the page. Clicking this button shows a form that allows you to create an A/B test with the desired traffic split and duration. You can also set a filter so that Dynamic Re-Ranking only re-ranks records that match the filter. This way, you can prevent, for example, Dynamic Re-Ranking from promoting items that aren’t in stock.

Did you find this page helpful?