Skip to content

Commit 39f8263

Browse files
authored
Merge pull request #1116 from nnethercott/disable-on-numbers
Add `disableOnNumbers` to typo tolerance settings
2 parents 2b436e9 + 50f201a commit 39f8263

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

.code-samples.meilisearch.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ typo_tolerance_guide_4: |-
360360
'twoTypos': 10
361361
}
362362
})
363+
typo_tolerance_guide_5: |-
364+
client.index('movies').update_typo_tolerance({
365+
'disableOnNumbers': True
366+
})
363367
search_parameter_guide_show_ranking_score_1: |-
364368
client.index('movies').search('dragon', {
365369
'showRankingScore': True

meilisearch/models/index.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class MinWordSizeForTypos(CamelBase):
4444

4545
class TypoTolerance(CamelBase):
4646
enabled: bool = True
47+
disable_on_numbers: bool = False
4748
disable_on_attributes: Optional[List[str]] = None
4849
disable_on_words: Optional[List[str]] = None
4950
min_word_size_for_typos: Optional[MinWordSizeForTypos] = None

tests/settings/test_settings_typo_tolerance_meilisearch.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from meilisearch.models.index import TypoTolerance
2+
13
DEFAULT_TYPO_TOLERANCE = {
24
"enabled": True,
5+
"disableOnNumbers": False,
36
"minWordSizeForTypos": {
47
"oneTypo": 5,
58
"twoTypos": 9,
@@ -10,6 +13,7 @@
1013

1114
NEW_TYPO_TOLERANCE = {
1215
"enabled": True,
16+
"disableOnNumbers": False,
1317
"minWordSizeForTypos": {
1418
"oneTypo": 6,
1519
"twoTypos": 10,
@@ -65,3 +69,16 @@ def test_reset_typo_tolerance(empty_index):
6569
)
6670
assert update2.status == "succeeded"
6771
assert response_last.model_dump(by_alias=True) == DEFAULT_TYPO_TOLERANCE
72+
73+
74+
def test_disable_numbers_true(empty_index):
75+
index = empty_index()
76+
77+
# Update settings
78+
response_update = index.update_typo_tolerance({"disableOnNumbers": True})
79+
update = index.wait_for_task(response_update.task_uid)
80+
assert update.status == "succeeded"
81+
82+
# Fetch updated settings
83+
tolerance: TypoTolerance = index.get_typo_tolerance()
84+
assert tolerance.disable_on_numbers

0 commit comments

Comments
 (0)