- âdog foodâ is an exact match for âdog foodâ
- âdog fodâ is an inexact match for âdog foodâ
- âfood for dogsâ is an exact matches for the individual words âfoodâ and âdogsâ, but an inexact match for âdog foodâ.
The Exact criterion counter
The Exact criterion is a counter: for every exact matching word in an attribute, the count increases by 1. The higher the count, the higher the record is ranked. The count ranges from 0 to the number of words in the query.- Exact words are only counted once per record. If the same word has 10 exact matches in a record, whether in the same attribute or not, that query word still gets only 1 point.
- Synonyms and singular/plural forms of a word are treated as exact matches. For example, âdogâ and âdogsâ are exact matches.
Multi-word queries
The counter works with single or multi-word queries, but every word is treated separately.- If the query contains two words with exact matches in the same attribute, thatâs 2 points, 1 for each match.
- If the first word matches in one attribute, and the second in another, thatâs also 2 points.
Multi-word attributes
Single-word matches in multi-word attributes arenât considered exact matches by default. For example, for the single-word query âroad,â only a record with an attribute containing just âroadâ is considered to be an exact match. A record with an attribute containing the term âroad tripâ isnât an exact match.Exact versus Words criteria scores
A recordâs Exact criterion score differs from the Words criterion score because the Words criterion considers inexact matches. A recordâs Exact score may be less than the number of query words because of inexact matches or theoptionalWords setting.
For example, for the query âiPhon 14â, a record containing âiPhone 14â would have a Words score of 2 and an Exact score of 1.
Adjustments to the Exact settings
You can change the settings to make single-word queries behave differently or to turn off Exact for some attributes. This can help users find what theyâre looking for.Single-word queries
By default, Algolia handles single-word and multi-word queries differently:- Single-word queries increment the count when they fully match single-word attributes
- Multi-word queries increment the count when thereâs a match for any word in a multi-word attribute.
exactOnSingleWordQuery to word.
Consider doing this if you donât have many important single-word attributes and want matches on single-word and multi-word attributes to rank evenly. The query word must be at least 3 characters long and must not be a stop word in any supported language.
For example, you search for âRoadâ in a TV database site, and there are two records with âRoadâ and âRoad Tripâ as the title attribute:
exactOnSingleWordQuery=attribute(the default). Only matches the record with âRoadâ as thetitleexactOnSingleWordQuery=word. Matches both âRoadâ and âRoad Tripâ.
Turn off Exact for some attributes
You can turn off the Exact ranking criterion for some attributes with thedisableExactOnAttributes setting.
Consider doing this if you have text-heavy attributes such as description that makes exact matching more likely and less useful for ranking.
Doing this gives attributes with shorter content, such as title or name, more control over ranking.
Plurals and synonyms
By default, Algolia counts singular and plural forms, and single-word synonym matches as exact matches. For example, if you have a synonym for âswimwearâ and âswimsuitâ, a search for âswimwearâ will count as an exact match on a record with the word âswimsuitâ. Multi-word synonyms arenât counted as exact matches. While the default behavior works well in most cases, you can customize it with thealternativesAsExact setting.