disableTypoToleranceOnAttributes
'disableTypoToleranceOnAttributes' => [ 'attribute', ... ]
Can be used in these methods:
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
set_settings,
browse_objects,
search_for_facet_values,
generate_secured_api_key,
add_api_key,
update_api_key
search,
setSettings,
browse,
searchForFacetValues,
generateSecuredApiKey,
addAPIKey,
updateAPIKey
search,
setSettings,
browseObjects,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
Browse,
SearchForFacetValues,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
setSettings,
browse,
searchForFacetValues,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
SetSettings,
BrowseObjects,
SearchForFacetValues,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
setSettings,
browse index,
search into facet values,
generateSecuredApiKey,
add key,
update key
About this parameter
A list of searchable attributes for which you want to turn off typo tolerance.
Turning off typo tolerance on attributes means that any user query must exactly match an attribute’s value. This can be useful when:
- Searching for hyphenated numbers, such as SKUs or telephone numbers. See Searching in hyphenated attributes
- Searching attributes with long blocks of text, such as
description
fields (especially if the field isn’t displayed on-screen). If you find you have too many results, enablingdisableTypoToleranceOnAttributes
, combined withdisablePrefixOnAttributes
, will reduce the number of hits on such fields. This is useful for user-generated content (which may have spelling mistakes), product descriptions (which may contain several product names), or any long-form text content.
disableTypoToleranceOnAttributes
may not be the best choice for other scenarios, such as:
- Intentional misspellings in things like the
title
field in a movie dataset (for example, “The Pursuit of Happyness”). Instead, consider creating a list of words fordisableTypoToleranceOnWords
or adding synonyms ( with thesaveSynonyms
method, CLI, or dashboard) - When using fields that contain things like the exact names of people, places, or products. Instead, consider increasing typo tolerance to allow users to enter their best guess spellings.
Usage notes
- The list must be a subset of the
searchableAttributes
index setting. searchableAttributes
mustn’t be empty or null fordisableTypoToleranceOnAttributes
to be applied.
There’s no limit to the number of attributes in the list, but having many attributes slows down calls to getSettings
. This can make the Algolia dashboard slower and less responsive.
Examples
Turn off typo tolerance for some attributes by default
1
2
3
4
5
$index->setSettings([
'disableTypoToleranceOnAttributes' => [
'sku',
]
]);
Turn off typo tolerance for some attributes for the current search
1
2
3
4
5
$results = $index->search('query', [
'disableTypoToleranceOnAttributes' => [
'sku'
]
]);