mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 11:57:07 +02:00
feat(search, update): synonyms
This commit is contained in:
parent
995d1a07d4
commit
e39aabbfe6
4 changed files with 132 additions and 26 deletions
|
@ -260,6 +260,9 @@ struct Settings {
|
|||
|
||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||
stop_words: Setting<BTreeSet<String>>,
|
||||
|
||||
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
|
||||
synonyms: Setting<HashMap<String, Vec<String>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -431,6 +434,13 @@ async fn main() -> anyhow::Result<()> {
|
|||
Setting::NotSet => ()
|
||||
}
|
||||
|
||||
// We transpose the settings JSON struct into a real setting update.
|
||||
match settings.synonyms {
|
||||
Setting::Set(synonyms) => builder.set_synonyms(synonyms),
|
||||
Setting::Reset => builder.reset_synonyms(),
|
||||
Setting::NotSet => ()
|
||||
}
|
||||
|
||||
let result = builder.execute(|indexing_step, update_id| {
|
||||
let (current, total) = match indexing_step {
|
||||
TransformFromUserIntoGenericFormat { documents_seen } => (documents_seen, None),
|
||||
|
@ -1011,6 +1021,7 @@ mod tests {
|
|||
faceted_attributes: Setting::Set(hashmap! { "age".into() => "integer".into() }),
|
||||
criteria: Setting::Set(vec!["asc(age)".to_string()]),
|
||||
stop_words: Setting::Set(btreeset! { "and".to_string() }),
|
||||
synonyms: Setting::NotSet
|
||||
};
|
||||
|
||||
assert_tokens(&settings, &[
|
||||
|
@ -1053,6 +1064,7 @@ mod tests {
|
|||
faceted_attributes: Setting::Reset,
|
||||
criteria: Setting::Reset,
|
||||
stop_words: Setting::Reset,
|
||||
synonyms: Setting::NotSet
|
||||
};
|
||||
|
||||
assert_tokens(&settings, &[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue