From 61b58b115a5dcfe7b0dc701c722f4832abdc747a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Mon, 28 Nov 2022 16:32:28 +0100 Subject: [PATCH] Don't create partial matching words for synonyms in ngrams --- milli/src/search/query_tree.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/milli/src/search/query_tree.rs b/milli/src/search/query_tree.rs index 6ea82f165..e689ae440 100755 --- a/milli/src/search/query_tree.rs +++ b/milli/src/search/query_tree.rs @@ -693,11 +693,13 @@ fn create_matching_words( if let Some(synonyms) = ctx.synonyms(&words)? { for synonym in synonyms { - let synonym = synonym + if let Some(synonym) = synonym .into_iter() - .flat_map(|syn| matching_word_cache.insert(syn, 0, false)) - .collect(); - matching_words.push((synonym, ids.clone())); + .map(|syn| matching_word_cache.insert(syn, 0, false)) + .collect() + { + matching_words.push((synonym, ids.clone())); + } } } let word = words.concat();