Icon ranking white

Ranking Formula

Last updated 03 July 2017

Ranking

Algolia’s ranking strategy leverages our tie-breaking algorithm, handling challenging search problems such as typos, geo located results, exact matches and more, in combination with both your data’s textual, and business relevant attributes.

Using our proprietary algorithm in combination with your data attributes, Algolia creates a unique relevancy and ranking algorithm that returns relevant results from the first keystroke of a user’s query.

Tie-breaking Approach

Most search engines use a coefficient-based approach and rank results based on a unique float value that is hard, if not impossible, to decipher.

To improve the relevance of the engine, Algolia built our tie-breaking algorithm, here’s how it works:

  • All the matching records are sorted according to the first criterion.
  • If any records are tied, those records are then sorted according to the second criterion.
  • If there are still records that are tied, those are then sorted according to the third criterion and so on, until each record in the search results has a distinct position.

Minimum Suggested Configuration

We recommend using the out-of-the-box ranking formula as works well for the vast majority of use cases. You can, however, modify the order of rules if necessary.

The Algolia Ranking Formula

The 7 ranking criterion of our tie-breaking algorithm help us define what is both textually and business relevant.

Typo

Algolia can retrieve the words searched by the user even if a typing mistake was made, and by default, we’ll match words that have 0, 1 or 2 typos. The criterion Typo in the ranking formula makes sure that a word without typos will be ranked higher than one with 1 typo, themselves being ranked higher than the ones with 2 typos and so on.

Geo (if applicable)

If you’re utilizing the geo-search features of our engine, we will rank the results by distance, from the closest to the furthest. The precision of this ranking is set by the parameter aroundPrecision.

For example, with aroundPrecision=100, two results up to 100 meters close will be considered equal.

Words (if applicable)

By default, Algolia discards all results that don’t contain all the words of the query. If you declared some words as optional, this rule will rank them by number of words typed by the user that matched.

This criterion is not counting the number of times the word appears in the record, but rather counting the number of words typed by the user that matched.

For example, if the user typed 2 words, the maximal score for this criterion is 2 - even if a record contains this word 10 times.

Proximity

For a query that contains two or more words, Proximity calculates how physically near are those words in the matching record. This criterion will rank higher the objects that have the words closer to each other.

For example, George Clooney is a better proximity match than George word Clooney.

Attribute

This criterion is the one taking into account the settings that you have selected in the searchableAttributes (also referred to as AttributesToIndex):

The order of the attributes will be used to rank higher the objects that have matched in an attribute placed on top of the list of indexed attributes. If you have selected Ordered, we’ll rank higher the objects whose matching words are at the beginning of a given attribute.

Exact

Records with words (not just prefixes) that exactly match the query terms are ranked higher.

Custom

This criterion is the one taking into account the settings that you have selected in Custom Ranking - defined below.

If you have multiple attributes in your Custom Ranking, the behavior will be the same than for the rest of the Ranking Formula: we’ll only look at a criterion to refine the ranking when there is an equality on all the previous criteria.

For example, if you have the following Custom Ranking:

Customranking

With featured being either true or false and number_of_likes being a numerical value.

The objects that have the same ranking after the 6 first criteria will then be ranked between them this way:

  • Featured objects, ranked from the most to the least liked
  • Not featured objects, ranked from the most to the least liked

What’s next

Continue building your Algolia knowledge with these concepts:

© Algolia - Privacy Policy