- “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 thetitle
exactOnSingleWordQuery
=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.