Skip to content

Commit 6cf84f5

Browse files
meili-bors[bot]vishalsodaniomid
authored
Merge #480
480: Add support for typo tolerance customization r=bidoubiwa a=omid It's coming after #351 PR. I fixed the comments of the other PR here. fixes #260 Co-authored-by: vishalsodani <[email protected]> Co-authored-by: Omid Rad <[email protected]> Co-authored-by: Omid Rad <[email protected]>
2 parents d63bec5 + 51f52dc commit 6cf84f5

File tree

2 files changed

+344
-13
lines changed

2 files changed

+344
-13
lines changed

.code-samples.meilisearch.yaml

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,17 @@ update_settings_1: |-
293293
synonyms.insert(String::from("wolverine"), vec!["xmen", "logan"]);
294294
synonyms.insert(String::from("logan"), vec!["wolverine"]);
295295
296+
let min_word_size_for_typos = MinWordSizeForTypos {
297+
one_typo: Some(4),
298+
two_typos; Some(12)
299+
}
300+
let typo_tolerance = TypoToleranceSettings {
301+
enabled: Some(true),
302+
disable_on_attributes: Some(vec!["title".to_string()]),
303+
disable_on_words: Some(vec![])
304+
min_word_size_for_typos: Some(min_word_size_for_typos),
305+
};
306+
296307
let settings = Settings::new()
297308
.with_ranking_rules([
298309
"words",
@@ -325,7 +336,8 @@ update_settings_1: |-
325336
"title",
326337
"release_date"
327338
])
328-
.with_synonyms(synonyms);
339+
.with_synonyms(synonyms)
340+
.with_typo_tolerance(typo_tolerance);
329341
330342
let task: TaskInfo = client
331343
.index("movies")
@@ -381,6 +393,48 @@ reset_pagination_settings_1: |-
381393
.reset_pagination()
382394
.await
383395
.unwrap();
396+
getting_started_typo_tolerance: |-
397+
let min_word_size_for_typos = MinWordSizeForTypos {
398+
one_typo: Some(5),
399+
two_typos: Some(4)
400+
}
401+
let typo_tolerance = TypoToleranceSettings {
402+
enabled: Some(true),
403+
disable_on_attributes: Some(vec![]),
404+
disable_on_words: Some(vec!["title".to_string()]),
405+
min_word_size_for_typos: Some(min_word_size_for_typos),
406+
};
407+
408+
let task: TaskInfo = client
409+
.index("movies")
410+
.set_typo_tolerance(&typo_tolerance)
411+
.await
412+
.unwrap();
413+
get_typo_tolerance_1: |-
414+
let typo_tolerance: TypoToleranceSettings = client
415+
.index("books")
416+
.get_typo_tolerance()
417+
.await
418+
.unwrap();
419+
update_typo_tolerance_1: |-
420+
let typo_tolerance = TypoToleranceSettings {
421+
enabled: Some(false),
422+
disable_on_attributes: None,
423+
disable_on_words: None,
424+
min_word_size_for_typos: None,
425+
};
426+
427+
let task: TaskInfo = client
428+
.index("books")
429+
.set_typo_tolerance(&typo_tolerance)
430+
.await
431+
.unwrap();
432+
reset_typo_tolerance_1: |-
433+
let task: TaskInfo = client
434+
.index("books")
435+
.reset_typo_tolerance()
436+
.await
437+
.unwrap();
384438
get_stop_words_1: |-
385439
let stop_words: Vec<String> = client
386440
.index("movies")
@@ -783,6 +837,90 @@ settings_guide_filterable_attributes_1: |-
783837
.set_settings(&settings)
784838
.await
785839
.unwrap();
840+
settings_guide_typo_tolerance_1: |-
841+
let min_word_size_for_typos = MinWordSizeForTypos {
842+
one_typo: Some(5),
843+
two_typos: Some(12)
844+
}
845+
let typo_tolerance = TypoToleranceSettings {
846+
enabled: Some(true),
847+
disable_on_attributes: None,
848+
disable_on_words: Some(vec!["title".to_string()]),
849+
min_word_size_for_typos: Some(min_word_size_for_typos),
850+
};
851+
852+
let settings = Settings::new()
853+
.with_typo_tolerance(&typo_tolerance);
854+
855+
let task: TaskInfo = client
856+
.index("movies")
857+
.set_settings(&settings)
858+
.await
859+
.unwrap();
860+
typo_tolerance_guide_1: |-
861+
let typo_tolerance = TypoToleranceSettings {
862+
enabled: Some(false),
863+
disable_on_attributes: None,
864+
disable_on_words: None,
865+
min_word_size_for_typos: None,
866+
};
867+
868+
let task: TaskInfo = client
869+
.index("movies")
870+
.set_typo_tolerance(&typo_tolerance)
871+
.await
872+
.unwrap();
873+
typo_tolerance_guide_2: |-
874+
let min_word_size_for_typos = MinWordSizeForTypos {
875+
one_typo: Some(5),
876+
two_typos: Some(12)
877+
}
878+
let typo_tolerance = TypoToleranceSettings {
879+
enabled: Some(true),
880+
disable_on_attributes: Some(vec!["title".to_string()]),
881+
disable_on_words: None,
882+
min_word_size_for_typos: None,
883+
};
884+
885+
let task: TaskInfo = client
886+
.index("movies")
887+
.set_typo_tolerance(&typo_tolerance)
888+
.await
889+
.unwrap();
890+
typo_tolerance_guide_3: |-
891+
let min_word_size_for_typos = MinWordSizeForTypos {
892+
one_typo: Some(5),
893+
two_typos: Some(12)
894+
}
895+
let typo_tolerance = TypoToleranceSettings {
896+
enabled: Some(true),
897+
disable_on_attributes: None,
898+
disable_on_words: Some(vec!["shrek".to_string()]),
899+
min_word_size_for_typos: Some(min_word_size_for_typos),
900+
};
901+
902+
let task: TaskInfo = client
903+
.index("movies")
904+
.set_typo_tolerance(&typo_tolerance)
905+
.await
906+
.unwrap();
907+
typo_tolerance_guide_4: |-
908+
let min_word_size_for_typos = MinWordSizeForTypos {
909+
one_typo: Some(4),
910+
two_typos: Some(12)
911+
};
912+
let typo_tolerance = TypoToleranceSettings {
913+
enabled: Some(true),
914+
disable_on_attributes: Some(vec![]),
915+
disable_on_words: Some(vec!["title".to_string()]),
916+
min_word_size_for_typos: Some(min_word_size_for_typos),
917+
};
918+
919+
let task: TaskInfo = client
920+
.index("movies")
921+
.set_typo_tolerance(&typo_tolerance)
922+
.await
923+
.unwrap();
786924
add_movies_json_1: |-
787925
use meilisearch_sdk::{
788926
indexes::*,

0 commit comments

Comments
 (0)