API Reference / API Parameters / typoTolerance
Feb. 26, 2019

typoTolerance

Type: string | boolean
Engine default: true
Parameter syntax
'typoTolerance' => true|false|'min'|'strict'

Can be used in these methods:

About this parameter

Controls whether typo tolerance is enabled and how it is applied.

Usage notes:

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 the typo 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'
]);
1
2
3
4
5
6
$results = $index->search('query', [
  'typoTolerance' => false
  // 'typoTolerance' => true
  // 'typoTolerance' => 'min'
  // 'typoTolerance' => 'strict'
]);

Did you find this page helpful?