Skip to content

v1.15: Disable typo tolerance on numbers #3258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: v1.15
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,13 @@ typo_tolerance_guide_4: |-
"twoTypos": 10
}
}'
typo_tolerance_guide_5: |-
curl \
-X PATCH 'MEILISEARCH_URL/indexes/movies/settings/typo-tolerance' \
-H 'Content-Type: application/json' \
--data-binary '{
"disableOnNumbers": true
}'
updating_guide_check_version_new_authorization_header: |-
curl \
-X GET 'http://<your-domain-name>/version' \
Expand Down
10 changes: 10 additions & 0 deletions learn/relevancy/typo_tolerance_settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ You can disable typo tolerance for a specific [document attribute](/learn/gettin
<CodeSamplesTypoToleranceGuide2 />

With the above settings, matches in the `title` attribute will not tolerate any typos. For example, a search for `beautiful` (9 characters) will not match the movie "Biutiful" starring Javier Bardem. With the default settings, this would be a match.

## `disableOnNumbers`

By default, typo tolerance on numerical values is turned on. This may lead to false positives: a search for `2024` is likely to match terms such as `2025` and `2004`.

You can disable typo tolerance for all numeric values across all indexes and search requests:

<CodeSamplesTypoToleranceGuide5 />

When `disableOnNumbers` is set to `true`, queries with numbers only return exact matches. Besides reducing the number of false positives, disabling typo tolerance on numbers may also improve indexing performance.
3 changes: 3 additions & 0 deletions reference/api/settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,7 @@ Typo tolerance helps users find relevant results even when their search queries
| **`minWordSizeForTypos.twoTypos`** | Integer | `9` | The minimum word size for accepting 2 typos; must be between `oneTypo` and `255` |
| **`disableOnWords`** | Array of strings | Empty | An array of words for which the typo tolerance feature is disabled |
| **`disableOnAttributes`** | Array of strings | Empty | An array of attributes for which the typo tolerance feature is disabled |
| **`disableOnNumbers`** | Boolean | `false` | Whether typo tolerance for numbers is disabled or enabled |

### Get typo tolerance settings

Expand Down Expand Up @@ -2401,6 +2402,7 @@ Partially update the typo tolerance settings for an index.
},
"disableOnWords": [<String>, <String>, …],
"disableOnAttributes": [<String>, <String>, …]
"disableOnNumbers": <Boolean>,
}
```

Expand All @@ -2411,6 +2413,7 @@ Partially update the typo tolerance settings for an index.
| **`minWordSizeForTypos.twoTypos`** | Integer | `9` | The minimum word size for accepting 2 typos; must be between `oneTypo` and `255` |
| **`disableOnWords`** | Array of strings | Empty | An array of words for which the typo tolerance feature is disabled |
| **`disableOnAttributes`** | Array of strings | Empty | An array of attributes for which the typo tolerance feature is disabled |
| **`disableOnNumbers`** | Boolean | `false` | Whether typo tolerance for numbers is disabled or enabled |

#### Example

Expand Down
Loading