diff --git a/milli/src/search/new/graph_based_ranking_rule.rs b/milli/src/search/new/graph_based_ranking_rule.rs index 88df56448..b8c58c726 100644 --- a/milli/src/search/new/graph_based_ranking_rule.rs +++ b/milli/src/search/new/graph_based_ranking_rule.rs @@ -110,7 +110,7 @@ impl<'ctx, G: RankingRuleGraphTrait> RankingRule<'ctx, QueryGraph> for GraphBase match terms_matching_strategy { TermsMatchingStrategy::Last => { let removal_order = - query_graph.removal_order_for_terms_matching_strategy_last(); + query_graph.removal_order_for_terms_matching_strategy_last(ctx); let mut forbidden_nodes = SmallBitmap::for_interned_values_in(&query_graph.nodes); let mut costs = query_graph.nodes.map(|_| None); diff --git a/milli/src/search/new/mod.rs b/milli/src/search/new/mod.rs index 92e8882be..588b89123 100644 --- a/milli/src/search/new/mod.rs +++ b/milli/src/search/new/mod.rs @@ -78,7 +78,7 @@ fn resolve_maximally_reduced_query_graph( let nodes_to_remove = match matching_strategy { TermsMatchingStrategy::Last => query_graph - .removal_order_for_terms_matching_strategy_last() + .removal_order_for_terms_matching_strategy_last(ctx) .iter() .flat_map(|x| x.iter()) .collect(), diff --git a/milli/src/search/new/query_graph.rs b/milli/src/search/new/query_graph.rs index faa487299..fc0b5e4d3 100644 --- a/milli/src/search/new/query_graph.rs +++ b/milli/src/search/new/query_graph.rs @@ -296,7 +296,10 @@ impl QueryGraph { } } - pub fn removal_order_for_terms_matching_strategy_last(&self) -> Vec> { + pub fn removal_order_for_terms_matching_strategy_last( + &self, + ctx: &SearchContext, + ) -> Vec> { let (first_term_idx, last_term_idx) = { let mut first_term_idx = u8::MAX; let mut last_term_idx = 0u8; @@ -329,6 +332,9 @@ impl QueryGraph { let mut nodes_to_remove = BTreeMap::>::new(); 'outer: for (node_id, node) in self.nodes.iter() { let QueryNodeData::Term(t) = &node.data else { continue }; + if ctx.term_interner.get(t.term_subset.original).zero_typo.phrase.is_some() { + continue; + } let mut cost = 0; for id in t.term_ids.clone() { if let Some(t_cost) = cost_of_term_idx(id) { diff --git a/milli/src/search/new/words.rs b/milli/src/search/new/words.rs index 710af2243..0036694c3 100644 --- a/milli/src/search/new/words.rs +++ b/milli/src/search/new/words.rs @@ -31,7 +31,7 @@ impl<'ctx> RankingRule<'ctx, QueryGraph> for Words { } fn start_iteration( &mut self, - _ctx: &mut SearchContext<'ctx>, + ctx: &mut SearchContext<'ctx>, _logger: &mut dyn SearchLogger, _parent_candidates: &RoaringBitmap, parent_query_graph: &QueryGraph, @@ -40,7 +40,7 @@ impl<'ctx> RankingRule<'ctx, QueryGraph> for Words { self.query_graph = Some(parent_query_graph.clone()); self.nodes_to_remove = match self.terms_matching_strategy { TermsMatchingStrategy::Last => { - let mut ns = parent_query_graph.removal_order_for_terms_matching_strategy_last(); + let mut ns = parent_query_graph.removal_order_for_terms_matching_strategy_last(ctx); ns.reverse(); ns }