Skip to content

Add support for typo tolerance customization #351

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

Closed
Closed
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
226 changes: 225 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ update_settings_1: |-
synonyms.insert(String::from("wolverine"), vec!["xmen", "logan"]);
synonyms.insert(String::from("logan"), vec!["wolverine"]);

let min_word_size_for_typos = MinWordSizeForTypos {
one_typo: Some(4),
two_typos; Some(12)
}
let typo_tolerance = TypoToleranceSettings {
enabled: Some(true),
disable_on_attributes: Some(vec!["title".to_string()]),
disable_on_words: Some(vec![])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disable_on_words: Some(vec![])

The fields that are not required should not be added to the samples. Normally this should not raise an error, right?

min_word_size_for_typos: Some(min_word_size_for_typos),
};

let settings = Settings::new()
.with_ranking_rules([
"words",
Expand Down Expand Up @@ -309,7 +320,8 @@ update_settings_1: |-
"title",
"release_date"
])
.with_synonyms(synonyms);
.with_synonyms(synonyms)
.with_typo_tolerance(typo_tolerance);

let task: TaskInfo = client
.index("movies")
Expand Down Expand Up @@ -365,6 +377,48 @@ reset_pagination_settings_1: |-
.reset_pagination()
.await
.unwrap();
getting_started_typo_tolerance: |-
let min_word_size_for_typos = MinWordSizeForTypos {
one_typo: Some(5),
two_typos: Some(4)
}
let typo_tolerance = TypoToleranceSettings {
enabled: Some(true),
disable_on_attributes: Some(vec![]),
disable_on_words: Some(vec!["title".to_string()]),
min_word_size_for_typos: Some(min_word_size_for_typos),
};

let task: TaskInfo = client
.index("movies")
.set_typo_tolerance(&typo_tolerance)
.await
.unwrap();
get_typo_tolerance_1: |-
let typo_tolerance: TypoToleranceSettings = client
.index("books")
.get_typo_tolerance()
.await
.unwrap();
update_typo_tolerance_1: |-
let typo_tolerance = TypoToleranceSettings {
enabled: Some(false),
disable_on_attributes: Some(vec![]),
disable_on_words: Some(vec![]),
min_word_size_for_typos: Some(MinWordSizeForTypos::default()),
};

let task: TaskInfo = client
.index("books")
.set_typo_tolerance(&typo_tolerance)
.await
.unwrap();
reset_typo_tolerance_1: |-
let task: TaskInfo = client
.index("books")
.reset_typo_tolerance()
.await
.unwrap();
get_stop_words_1: |-
let stop_words: Vec<String> = client
.index("movies")
Expand Down Expand Up @@ -767,6 +821,176 @@ settings_guide_filterable_attributes_1: |-
.set_settings(&settings)
.await
.unwrap();
settings_guide_ranking_rules_1: |-
let settings = Settings::new()
.with_ranking_rules([
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
"release_date:asc",
"rank:desc",
]);

let task: TaskInfo = client
.index("movies")
.set_settings(&settings)
.await
.unwrap();
settings_guide_distinct_1: |-
let settings = Settings::new()
.with_distinct_attribute("product_id");

let task: TaskInfo = client
.index("jackets")
.set_settings(&settings)
.await
.unwrap();
settings_guide_searchable_1: |-
let settings = Settings::new()
.with_searchable_attributes([
"title",
"overview",
"genres"
]);

let task: TaskInfo = client
.index("movies")
.set_settings(&settings)
.await
.unwrap();
settings_guide_pagination_1: |-
let pagination = PaginationSetting {max_total_hits:100};

let task: TaskInfo = client
.index("movies")
.set_pagination(pagination)
.await
.unwrap();
settings_guide_displayed_1: |-
let settings = Settings::new()
.with_displayed_attributes([
"title",
"overview",
"genres",
"release_date"
]);

let task: TaskInfo = client
.index("movies")
.set_settings(&settings)
.await
.unwrap();
settings_guide_sortable_1: |-
let settings = Settings::new()
.with_sortable_attributes([
"author",
"price"
]);

let task: TaskInfo = client
.index("books")
.set_settings(&settings)
.await
.unwrap();
settings_guide_faceting_1: |-
let faceting = FacetingSettings {
max_values_per_facet: 5,
};
let settings = Settings::new()
.with_faceting(&faceting);

let task: TaskInfo = client
.index("movies")
.set_settings(&settings)
.await
.unwrap();
settings_guide_typo_tolerance_1: |-
let min_word_size_for_typos = MinWordSizeForTypos {
one_typo: Some(5),
two_typos: Some(12)
}
let typo_tolerance = TypoToleranceSettings {
enabled: Some(true),
disable_on_attributes: Some(vec![]),
disable_on_words: Some(vec!["title".to_string()]),
min_word_size_for_typos: Some(min_word_size_for_typos),
};

let settings = Settings::new()
.with_typo_tolerance(&typo_tolerance);

let task: TaskInfo = client
.index("movies")
.set_settings(&settings)
.await
.unwrap();
typo_tolerance_guide_1: |-
let typo_tolerance = TypoToleranceSettings {
enabled: Some(false),
disable_on_attributes: Some(vec![]),
disable_on_words: Some(vec![]),
min_word_size_for_typos: Some(MinWordSizeForTypos::default()),
};

let task: TaskInfo = client
.index("movies")
.set_typo_tolerance(&typo_tolerance)
.await
.unwrap();
typo_tolerance_guide_2: |-
let min_word_size_for_typos = MinWordSizeForTypos {
one_typo: Some(5),
two_typos: Some(12)
}
let typo_tolerance = TypoToleranceSettings {
enabled: Some(true),
disable_on_attributes: Some(vec!["title".to_string()]),
disable_on_words: Some(vec![]),
min_word_size_for_typos: Some(min_word_size_for_typos),
};

let task: TaskInfo = client
.index("movies")
.set_typo_tolerance(&typo_tolerance)
.await
.unwrap();
typo_tolerance_guide_3: |-
let min_word_size_for_typos = MinWordSizeForTypos {
one_typo: Some(5),
two_typos: Some(12)
}
let typo_tolerance = TypoToleranceSettings {
enabled: Some(true),
disable_on_attributes: Some(vec![]),
disable_on_words: Some(vec!["shrek".to_string()]),
min_word_size_for_typos: Some(min_word_size_for_typos),
};

let task: TaskInfo = client
.index("movies")
.set_typo_tolerance(&typo_tolerance)
.await
.unwrap();
typo_tolerance_guide_4: |-
let min_word_size_for_typos = MinWordSizeForTypos {
one_typo: Some(4),
two_typos: Some(12)
};
let typo_tolerance = TypoToleranceSettings {
enabled: Some(true),
disable_on_attributes: Some(vec![]),
disable_on_words: Some(vec!["title".to_string()]),
min_word_size_for_typos: Some(min_word_size_for_typos),
};

let task: TaskInfo = client
.index("movies")
.set_typo_tolerance(&typo_tolerance)
.await
.unwrap();
add_movies_json_1: |-
use meilisearch_sdk::{
indexes::*,
Expand Down
Loading