Take the minimum between max_total_hits and local universe len when processing an hybrid search

This commit is contained in:
ManyTheFish
2025-08-19 10:21:34 +02:00
parent a608e57c3c
commit 82f3b759f8

View File

@ -41,7 +41,8 @@ pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>(
let distinct_fid = distinct_fid(distinct, ctx.index, ctx.txn)?;
if universe.len() < from as u64 {
let universe_len = universe.len() as usize;
if universe_len < from {
return Ok(BucketSortOutput {
docids: vec![],
scores: vec![],
@ -167,6 +168,9 @@ pub fn bucket_sort<'ctx, Q: RankingRuleQueryTrait>(
_ => length,
};
// if the universe is smaller than the max length to evaluate, we can stop early
let max_len_to_evaluate = std::cmp::min(universe_len, max_len_to_evaluate);
while valid_docids.len() < max_len_to_evaluate {
if time_budget.exceeded() {
loop {