API Reference / API Parameters / disableTypoToleranceOnAttributes

disableTypoToleranceOnAttributes

Type: list of strings
Engine default: []
Formerly: disableTypoToleranceOn
Parameter syntax
'disableTypoToleranceOnAttributes' => [
  'attribute',
  ...
]

Can be used in these methods:

About this parameter

A list of searchable attributes for which you want to turn off typo tolerance.

Turning off typo tolerance 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, enabling disableTypoToleranceOnAttributes, combined with disablePrefixOnAttributes, 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 for disableTypoToleranceOnWords or adding synonyms ( with the saveSynonyms 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 for disableTypoToleranceOnAttributes to be applied.

Examples

Turn off typo tolerance for some attributes by default

1
2
3
4
5
$index->setSettings([
  'disableTypoToleranceOnAttributes' => [
    'sku',
  ]
]);
1
2
3
4
5
$results = $index->search('query', [
  'disableTypoToleranceOnAttributes' => [
    'sku'
  ]
]);
Did you find this page helpful?