Merge pull request #5313 from barloes/fixRankingScoreThresholdRankingIssue

fix for rankingScoreThreshold changes the results' ranking
This commit is contained in:
Louis Dureuil 2025-04-01 13:10:55 +00:00 committed by GitHub
commit 418fa47963
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -173,16 +173,18 @@ pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>(
ranking_rule_scores.push(ScoreDetails::Skipped); ranking_rule_scores.push(ScoreDetails::Skipped);
// remove candidates from the universe without adding them to result if their score is below the threshold // remove candidates from the universe without adding them to result if their score is below the threshold
if let Some(ranking_score_threshold) = ranking_score_threshold { let is_below_threshold =
let current_score = ScoreDetails::global_score(ranking_rule_scores.iter()); ranking_score_threshold.is_some_and(|ranking_score_threshold| {
if current_score < ranking_score_threshold { let current_score = ScoreDetails::global_score(ranking_rule_scores.iter());
all_candidates -= bucket | &ranking_rule_universes[cur_ranking_rule_index]; current_score < ranking_score_threshold
back!(); });
continue;
}
}
maybe_add_to_results!(bucket); if is_below_threshold {
all_candidates -= &bucket;
all_candidates -= &ranking_rule_universes[cur_ranking_rule_index];
} else {
maybe_add_to_results!(bucket);
}
ranking_rule_scores.pop(); ranking_rule_scores.pop();
@ -237,23 +239,24 @@ pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>(
); );
// remove candidates from the universe without adding them to result if their score is below the threshold // remove candidates from the universe without adding them to result if their score is below the threshold
if let Some(ranking_score_threshold) = ranking_score_threshold { let is_below_threshold = ranking_score_threshold.is_some_and(|ranking_score_threshold| {
let current_score = ScoreDetails::global_score(ranking_rule_scores.iter()); let current_score = ScoreDetails::global_score(ranking_rule_scores.iter());
if current_score < ranking_score_threshold { current_score < ranking_score_threshold
all_candidates -= });
next_bucket.candidates | &ranking_rule_universes[cur_ranking_rule_index];
back!();
continue;
}
}
ranking_rule_universes[cur_ranking_rule_index] -= &next_bucket.candidates; ranking_rule_universes[cur_ranking_rule_index] -= &next_bucket.candidates;
if cur_ranking_rule_index == ranking_rules_len - 1 if cur_ranking_rule_index == ranking_rules_len - 1
|| (scoring_strategy == ScoringStrategy::Skip && next_bucket.candidates.len() <= 1) || (scoring_strategy == ScoringStrategy::Skip && next_bucket.candidates.len() <= 1)
|| cur_offset + (next_bucket.candidates.len() as usize) < from || cur_offset + (next_bucket.candidates.len() as usize) < from
|| is_below_threshold
{ {
maybe_add_to_results!(next_bucket.candidates); if is_below_threshold {
all_candidates -= &next_bucket.candidates;
all_candidates -= &ranking_rule_universes[cur_ranking_rule_index];
} else {
maybe_add_to_results!(next_bucket.candidates);
}
ranking_rule_scores.pop(); ranking_rule_scores.pop();
continue; continue;
} }