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 who 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.

Explore related videos in the Algolia Academy

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. Indirectly, Dynamic Re-Ranking will also demote less relevant results by boosting other results above them.

Dynamic Re-ranking can learn from user behavior patterns. For example, if users frequently choose surgical masks when searching for “mask”, it will increase the ranking of surgical masks in future results. This leads to a more relevant search experience and can result in a higher conversion rate without you having to create rules or use optional filters to tweak relevance.

Effect on relevance

While Dynamic Re-Ranking can be a powerful tool for 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 may also override an eventual Geo filtering.

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 Algolia has enough information to personalize results for a particular user)
  4. Boosting and burying categories with rules
  5. Dynamic Re-Ranking
  6. Pinning 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. Once you’ve sent some click and conversion events, you can 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.

If you use rules to pin top items for popular queries, Dynamic Re-Ranking has a limited effect. Turn off the rules in the simulator with the Rules toggle to assess the benefits of Dynamic Re-Ranking. Consider removing these rules if you’re satisfied with the records that Dynamic Re-Ranking promotes.

Dynamic Re-Ranking preparation

Dynamic Re-Ranking is available on the Build and Premium pricing plans.

Event requirements for Dynamic Re-Ranking

  • For a record to be promoted for a given search, this record must have received 20 click events or 2 conversion events after this specific search in the past 30 days
  • Events must contain a queryID property that corresponds to a valid search
  • An event timestamp must be within one hour of the search request’s timestamp and no older than four days at the time of sending
  • Events must include an objectID property that corresponds to a record currently in the specified index
  • Only one click or conversion event is considered per userToken per search query per record (objectID).

Click and conversion events

To use Dynamic Re-Ranking, you must send click and conversion events. Dynamic Re-Ranking uses this data to detect trends 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-day 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 duplicate events for the same user-query-record combination, only one counts for re-ranking For example, if the same user (same userToken) clicks on the same record 100 times after the same query, it counts as one click. If the same user clicks on the same record after different queries, they count as separate events.

To prevent users from 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 settings

Configure the following settings from the Dynamic Re-Ranking page in the dashboard.

Enable re-ranking on browsing pages (Browsing Facet)

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

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

If you set the root of a nested faceting attribute as a Browsing Facet, Re-ranking reorders 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 re-ranks empty queries filtered on hierarchicalCategories.level0 and hierarchicalCategories.level1 as well.

Turn off re-ranking for specific records (Re-Ranking Filter(s))

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

For example, if you select instock = true, Dynamic Re-Ranking only promotes items that are in stock.

Group Similar Queries

By default, each query is re-ranked independently. Group Similar Queries helps to re-rank less frequent query variations.

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

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

Re-rank more results per query (Re-ranked Hits)

You can increase the number of records pushed to the top of search results from the default of 20 to 100.

Dynamic Re-Ranking may promote fewer results than this value if Dynamic Re-Ranking doesn’t gather significant traffic on enough records.

Give more weight to recent events (Event Freshness)

To give more weight to recent events in the ranking computation, 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, Algolia recomputes re-ranking so that newer events have more weight than older ones. You don’t have to make any other changes.

Use a different events source index (Events source index)

By default, Dynamic Re-Ranking uses the events sent to the re-ranked index. Use another index as the source for the events by changing the Events source index option. The indices must be replicas or a copies of each other.

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 lets you 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?