diff --git a/meilisearch-core/src/bucket_sort.rs b/meilisearch-core/src/bucket_sort.rs index e15ea1079..8b2c7ebe5 100644 --- a/meilisearch-core/src/bucket_sort.rs +++ b/meilisearch-core/src/bucket_sort.rs @@ -69,8 +69,11 @@ where None => return Ok(Vec::new()), }; + let stop_words = main_store.stop_words_fst(reader)?.unwrap_or_default(); + let context = QTContext { words_set, + stop_words, synonyms: synonyms_store, postings_lists: postings_lists_store, prefix_postings_lists: prefix_postings_lists_cache_store, @@ -198,8 +201,11 @@ where None => return Ok(Vec::new()), }; + let stop_words = main_store.stop_words_fst(reader)?.unwrap_or_default(); + let context = QTContext { words_set, + stop_words, synonyms: synonyms_store, postings_lists: postings_lists_store, prefix_postings_lists: prefix_postings_lists_cache_store, diff --git a/meilisearch-core/src/query_tree.rs b/meilisearch-core/src/query_tree.rs index 3641f532f..e4965a656 100644 --- a/meilisearch-core/src/query_tree.rs +++ b/meilisearch-core/src/query_tree.rs @@ -114,6 +114,7 @@ pub struct PostingsList { pub struct Context { pub words_set: fst::Set, + pub stop_words: fst::Set, pub synonyms: store::Synonyms, pub postings_lists: store::PostingsLists, pub prefix_postings_lists: store::PrefixPostingsListsCache, @@ -180,6 +181,7 @@ pub fn create_query_tree( ) -> MResult<(Operation, HashMap>)> { let words = split_query_string(query).map(str::to_lowercase); + let words = words.filter(|w| !ctx.stop_words.contains(w)); let words: Vec<_> = words.enumerate().collect(); let mut mapper = QueryWordsMapper::new(words.iter().map(|(_, w)| w)); diff --git a/meilisearch-core/src/update/settings_update.rs b/meilisearch-core/src/update/settings_update.rs index 62e93725d..ed75b0cf1 100644 --- a/meilisearch-core/src/update/settings_update.rs +++ b/meilisearch-core/src/update/settings_update.rs @@ -171,6 +171,9 @@ pub fn apply_stop_words_update( )?; return Ok(true) } + + let stop_words_fst = fst::Set::from_iter(stop_words)?; + index.main.put_words_fst(writer, &stop_words_fst)?; Ok(false) }