Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion rust/lance-index/src/scalar/inverted/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1756,8 +1756,15 @@ impl PartialOrd for ScoredDoc {
}

impl Ord for ScoredDoc {
// Total order for the FTS top-k: score first, ties broken by ascending row_id (a lower row_id ranks
// higher, so it compares as "greater" here). A total tiebreak makes top-k a stable prefix across `k`
// (top-k1 is an ordered prefix of top-k2), which tied-score pagination needs. This orientation makes a
// min-heap's `peek` the worst candidate (lowest score, highest row_id) to evict first, and
// `into_sorted_vec` over `Reverse<ScoredDoc>` yield (score DESC, row_id ASC).
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.score.cmp(&other.score)
self.score
.cmp(&other.score)
.then_with(|| other.row_id.cmp(&self.row_id))
}
}

Expand Down
Loading
Loading