diff --git a/milli/src/search/new/graph_based_ranking_rule.rs b/milli/src/search/new/graph_based_ranking_rule.rs index 6602a81e2..a25d9c155 100644 --- a/milli/src/search/new/graph_based_ranking_rule.rs +++ b/milli/src/search/new/graph_based_ranking_rule.rs @@ -139,13 +139,12 @@ impl<'ctx, G: RankingRuleGraphTrait> RankingRule<'ctx, QueryGraph> for GraphBase let mut forbidden_nodes = SmallBitmap::for_interned_values_in(&query_graph.nodes); let mut costs = query_graph.nodes.map(|_| None); - let mut cost = 100; + // FIXME: this works because only words uses termsmatchingstrategy at the moment. for ns in removal_order { for n in ns.iter() { - *costs.get_mut(n) = Some((cost, forbidden_nodes.clone())); + *costs.get_mut(n) = Some((1, forbidden_nodes.clone())); } forbidden_nodes.union(&ns); - cost += 100; } costs } diff --git a/milli/src/search/new/ranking_rule_graph/build.rs b/milli/src/search/new/ranking_rule_graph/build.rs index 015cd9845..4bacc5e5d 100644 --- a/milli/src/search/new/ranking_rule_graph/build.rs +++ b/milli/src/search/new/ranking_rule_graph/build.rs @@ -49,10 +49,15 @@ impl RankingRuleGraph { if let Some((cost_of_ignoring, forbidden_nodes)) = cost_of_ignoring_node.get(dest_idx) { + let dest = graph_nodes.get(dest_idx); + let dest_size = match &dest.data { + QueryNodeData::Term(term) => term.term_ids.len(), + _ => panic!(), + }; let new_edge_id = edges_store.insert(Some(Edge { source_node: source_id, dest_node: dest_idx, - cost: *cost_of_ignoring, + cost: *cost_of_ignoring * dest_size as u32, condition: None, nodes_to_skip: forbidden_nodes.clone(), })); diff --git a/milli/src/search/new/ranking_rule_graph/words/mod.rs b/milli/src/search/new/ranking_rule_graph/words/mod.rs index 0a0cc112b..5b5ff5d08 100644 --- a/milli/src/search/new/ranking_rule_graph/words/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/words/mod.rs @@ -41,9 +41,6 @@ impl RankingRuleGraphTrait for WordsGraph { _from: Option<&LocatedQueryTermSubset>, to_term: &LocatedQueryTermSubset, ) -> Result)>> { - Ok(vec![( - to_term.term_ids.len() as u32, - conditions_interner.insert(WordsCondition { term: to_term.clone() }), - )]) + Ok(vec![(0, conditions_interner.insert(WordsCondition { term: to_term.clone() }))]) } }