Skip to content

Add disableOnNumbers to typo tolerance settings #1116

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ typo_tolerance_guide_4: |-
'twoTypos': 10
}
})
typo_tolerance_guide_5: |-
client.index('movies').update_typo_tolerance({
'disableOnNumbers': True
})
search_parameter_guide_show_ranking_score_1: |-
client.index('movies').search('dragon', {
'showRankingScore': True
Expand Down
1 change: 1 addition & 0 deletions meilisearch/models/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class MinWordSizeForTypos(CamelBase):

class TypoTolerance(CamelBase):
enabled: bool = True
disable_on_numbers: bool = False
disable_on_attributes: Optional[List[str]] = None
disable_on_words: Optional[List[str]] = None
min_word_size_for_typos: Optional[MinWordSizeForTypos] = None
Expand Down
17 changes: 17 additions & 0 deletions tests/settings/test_settings_typo_tolerance_meilisearch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from meilisearch.models.index import TypoTolerance

DEFAULT_TYPO_TOLERANCE = {
"enabled": True,
"disableOnNumbers": False,
"minWordSizeForTypos": {
"oneTypo": 5,
"twoTypos": 9,
Expand All @@ -10,6 +13,7 @@

NEW_TYPO_TOLERANCE = {
"enabled": True,
"disableOnNumbers": False,
"minWordSizeForTypos": {
"oneTypo": 6,
"twoTypos": 10,
Expand Down Expand Up @@ -65,3 +69,16 @@ def test_reset_typo_tolerance(empty_index):
)
assert update2.status == "succeeded"
assert response_last.model_dump(by_alias=True) == DEFAULT_TYPO_TOLERANCE


def test_disable_numbers_true(empty_index):
index = empty_index()

# Update settings
response_update = index.update_typo_tolerance({"disableOnNumbers": True})
update = index.wait_for_task(response_update.task_uid)
assert update.status == "succeeded"

# Fetch updated settings
tolerance: TypoTolerance = index.get_typo_tolerance()
assert tolerance.disable_on_numbers
Loading