diff --git a/milli/src/search/new/db_cache.rs b/milli/src/search/new/db_cache.rs index fb36c0d9f..6193f4c58 100644 --- a/milli/src/search/new/db_cache.rs +++ b/milli/src/search/new/db_cache.rs @@ -138,7 +138,7 @@ impl<'ctx> SearchContext<'ctx> { } /// Retrieve or insert the given value in the `word_prefix_docids` database. - pub fn get_db_word_prefix_docids( + fn get_db_word_prefix_docids( &mut self, prefix: Interned, ) -> Result> { diff --git a/milli/src/search/new/logger/visual.rs b/milli/src/search/new/logger/visual.rs index 068b5ad68..72e33f339 100644 --- a/milli/src/search/new/logger/visual.rs +++ b/milli/src/search/new/logger/visual.rs @@ -434,7 +434,7 @@ fill: \"#B6E2D3\" writeln!(file, "{}: phrase", p.description(ctx))?; } if let Some(w) = term_subset.use_prefix_db(ctx) { - let w = ctx.word_interner.get(w); + let w = ctx.word_interner.get(w.interned()); writeln!(file, "{w}: prefix db")?; } diff --git a/milli/src/search/new/query_term/mod.rs b/milli/src/search/new/query_term/mod.rs index 0a0d1a7eb..d8c2bb0c7 100644 --- a/milli/src/search/new/query_term/mod.rs +++ b/milli/src/search/new/query_term/mod.rs @@ -159,12 +159,12 @@ impl QueryTermSubset { self.two_typo_subset.intersect(&other.two_typo_subset); } - pub fn use_prefix_db(&self, ctx: &SearchContext) -> Option> { + pub fn use_prefix_db(&self, ctx: &SearchContext) -> Option { let original = ctx.term_interner.get(self.original); let Some(use_prefix_db) = original.zero_typo.use_prefix_db else { return None }; - match &self.zero_typo_subset { + let word = match &self.zero_typo_subset { NTypoTermSubset::All => Some(use_prefix_db), NTypoTermSubset::Subset { words, phrases: _ } => { // TODO: use a subset of prefix words instead @@ -175,7 +175,14 @@ impl QueryTermSubset { } } NTypoTermSubset::Nothing => None, - } + }; + word.map(|word| { + if original.ngram_words.is_some() { + Word::Derived(word) + } else { + Word::Original(word) + } + }) } pub fn all_single_words_except_prefix_db( &self, diff --git a/milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs b/milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs index 760c7272c..3e75f948e 100644 --- a/milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs +++ b/milli/src/search/new/ranking_rule_graph/proximity/compute_docids.rs @@ -55,7 +55,7 @@ pub fn compute_docids( compute_prefix_edges( ctx, left_word.interned(), - right_prefix, + right_prefix.interned(), left_phrase, forward_proximity, backward_proximity, diff --git a/milli/src/search/new/resolve_query_graph.rs b/milli/src/search/new/resolve_query_graph.rs index c78f0c5ee..f4938ca12 100644 --- a/milli/src/search/new/resolve_query_graph.rs +++ b/milli/src/search/new/resolve_query_graph.rs @@ -44,7 +44,7 @@ pub fn compute_query_term_subset_docids( } if let Some(prefix) = term.use_prefix_db(ctx) { - if let Some(prefix_docids) = ctx.get_db_word_prefix_docids(prefix)? { + if let Some(prefix_docids) = ctx.word_prefix_docids(prefix)? { docids |= prefix_docids; } }