From 2b43283522a9fc5cbbae7f2082b5cd3b661f5919 Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Thu, 3 Apr 2025 12:08:45 +0200 Subject: [PATCH] Force phrase search to check if every words are in the document --- crates/milli/src/search/new/matches/matching_words.rs | 2 +- crates/milli/src/search/new/resolve_query_graph.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/milli/src/search/new/matches/matching_words.rs b/crates/milli/src/search/new/matches/matching_words.rs index 64235298b..625dd2c77 100644 --- a/crates/milli/src/search/new/matches/matching_words.rs +++ b/crates/milli/src/search/new/matches/matching_words.rs @@ -174,7 +174,7 @@ impl<'a> PartialMatch<'a> { let is_matching = match matching_words.first()? { Some(word) => &token.lemma() == 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(), }; diff --git a/crates/milli/src/search/new/resolve_query_graph.rs b/crates/milli/src/search/new/resolve_query_graph.rs index 3bbe699b2..62b47be24 100644 --- a/crates/milli/src/search/new/resolve_query_graph.rs +++ b/crates/milli/src/search/new/resolve_query_graph.rs @@ -194,7 +194,11 @@ pub fn compute_phrase_docids( return Ok(RoaringBitmap::new()); } 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(candidates) = candidates.as_mut() { *candidates &= word_docids;