Add stop words on query

This commit is contained in:
qdequele
2020-02-10 16:50:55 +01:00
parent dc6907e748
commit 559c2f8907
3 changed files with 11 additions and 0 deletions

View File

@ -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));