Force phrase search to check if every words are in the document

This commit is contained in:
ManyTheFish 2025-04-03 12:08:45 +02:00
parent 0d9f7d2773
commit 2b43283522
2 changed files with 6 additions and 2 deletions

View File

@ -174,7 +174,7 @@ impl<'a> PartialMatch<'a> {
let is_matching = match matching_words.first()? { let is_matching = match matching_words.first()? {
Some(word) => &token.lemma() == word, Some(word) => &token.lemma() == word,
// a None value in the phrase corresponds to a stop word, // a None value in the phrase corresponds to a stop word,
// the walue is considered a match if the current token is categorized as a stop word. // the value is considered a match if the current token is categorized as a stop word.
None => token.is_stopword(), None => token.is_stopword(),
}; };

View File

@ -194,7 +194,11 @@ pub fn compute_phrase_docids(
return Ok(RoaringBitmap::new()); return Ok(RoaringBitmap::new());
} }
let mut candidates = None; let mut candidates = None;
for word in words.iter().flatten().copied() { for word in words.iter().copied() {
let Some(word) = word else {
continue;
};
if let Some(word_docids) = ctx.word_docids(None, Word::Original(word))? { if let Some(word_docids) = ctx.word_docids(None, Word::Original(word))? {
if let Some(candidates) = candidates.as_mut() { if let Some(candidates) = candidates.as_mut() {
*candidates &= word_docids; *candidates &= word_docids;