mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-29 16:24:26 +01:00
Add stop words on query
This commit is contained in:
parent
dc6907e748
commit
559c2f8907
@ -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,
|
||||
|
@ -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<QueryId, Range<usize>>)>
|
||||
{
|
||||
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));
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user