diff --git a/milli/src/search/new/ranking_rule_graph/position/mod.rs b/milli/src/search/new/ranking_rule_graph/position/mod.rs index d4640097e..9b0b6478f 100644 --- a/milli/src/search/new/ranking_rule_graph/position/mod.rs +++ b/milli/src/search/new/ranking_rule_graph/position/mod.rs @@ -111,23 +111,16 @@ impl RankingRuleGraphTrait for PositionGraph { fn cost_from_position(sum_positions: u32) -> u32 { match sum_positions { - 0 | 1 | 2 | 3 => sum_positions, - 4 | 5 => 4, - 6 | 7 => 5, - 8 | 9 => 6, - 10 | 11 => 7, - 12 | 13 => 8, - 14 | 15 => 9, - 16 | 17..=24 => 10, - 25..=32 => 11, - 33..=64 => 12, - 65..=128 => 13, - 129..=256 => 14, - 257..=512 => 15, - 513..=1024 => 16, - 1025..=2048 => 17, - 2049..=4096 => 18, - 4097..=8192 => 19, - _ => 20, + 0 => 0, + 1 => 1, + 2..=4 => 2, + 5..=7 => 3, + 8..=11 => 4, + 12..=16 => 5, + 17..=24 => 6, + 25..=64 => 7, + 65..=256 => 8, + 257..=1024 => 9, + _ => 10, } } diff --git a/milli/src/search/new/tests/attribute_position.rs b/milli/src/search/new/tests/attribute_position.rs index 5e16cd023..37f303b10 100644 --- a/milli/src/search/new/tests/attribute_position.rs +++ b/milli/src/search/new/tests/attribute_position.rs @@ -138,7 +138,7 @@ fn test_attribute_position_simple() { s.terms_matching_strategy(TermsMatchingStrategy::All); s.query("quick brown"); let SearchResult { documents_ids, .. } = s.execute().unwrap(); - insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 3, 4, 2, 1, 0, 6, 8, 7, 9, 5]"); + insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 2, 3, 4, 1, 0, 6, 8, 7, 9, 5]"); } #[test] fn test_attribute_position_repeated() { @@ -163,7 +163,7 @@ fn test_attribute_position_different_fields() { s.terms_matching_strategy(TermsMatchingStrategy::All); s.query("quick brown"); let SearchResult { documents_ids, .. } = s.execute().unwrap(); - insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 3, 4, 2, 1, 0, 6, 8, 7, 9, 5]"); + insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 2, 3, 4, 1, 0, 6, 8, 7, 9, 5]"); } #[test] @@ -176,5 +176,5 @@ fn test_attribute_position_ngrams() { s.terms_matching_strategy(TermsMatchingStrategy::All); s.query("quick brown"); let SearchResult { documents_ids, .. } = s.execute().unwrap(); - insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 3, 4, 2, 1, 0, 6, 8, 7, 9, 5]"); + insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 2, 3, 4, 1, 0, 6, 8, 7, 9, 5]"); }