typoTolerance
true
Can be used in these methods:
search,
setSettings,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
searchForFacetValues
search,
setSettings,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
searchAsync,
setSettingsAsync,
searchForFacetValues
Search,
SetSettings,
SearchForFacetValues,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
setSettings,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
SearchForFacetValues,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
setSettings,
search into facet values,
generateSecuredApiKey,
add key,
update key
About this parameter
Controls whether typo tolerance is enabled and how it is applied.
Usage notes:
- Algolia never returns records with more than 2 typos.
- If you use getRankingInfo, you can retrieve the number of typos for each result. Note that you could see 3 typos even with only 2 mistyped letters. This is because Algolia counts a typo on the first letter as 2 typos.
Options:
-
true: Typo tolerance is enabled and all records matching with or without typos are retrieved (default behavior).
-
false: Typo tolerance is entirely disabled. Only records matching without typos are retrieved.
-
min: Retrieve records with the smallest number of typos.
For example, if the smallest number of typos found is 0, then only records matching without typos will be returned. If the smallest number of typos found is 1, then only records matching with 1 typo will be returned.
-
strict: Retrieve records with the 2 smallest number of typos.
For example, if the smallest number of typos found is 0, then only records matching with 0 or 1 typo will be returned. If the smallest number of typos found is 1, then only records matching with 1 or 2 typos will be returned.
Strict changes the engine’s
ranking
, forcing thetypo criterion
to go the top of the ranking formula.
Examples
Set default typo tolerance mode
1
2
3
4
5
6
$index->setSettings([
'typoTolerance' => true
// 'typoTolerance' => false
// 'typoTolerance' => 'min'
// 'typoTolerance' => 'strict'
]);
Override default typo tolerance mode for the current search
1
2
3
4
5
6
$results = $index->search('query', [
'typoTolerance' => false
// 'typoTolerance' => true
// 'typoTolerance' => 'min'
// 'typoTolerance' => 'strict'
]);