mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-02-02 01:06:41 +08:00
fix: [2.6] BM25 with boost return result not ordered (#44759)
relate: https://github.com/milvus-io/milvus/issues/44758 pr: https://github.com/milvus-io/milvus/pull/44744 Wrong code which should be (result.seg_offsets_[i] >= 0 && result.seg_offsets_[j] < 0), but was (result.seg_offsets_[j] >= 0 && result.seg_offsets_[j] < 0) now. But because all placeholder which was offset -1, will fill with worst distance value. For IP, L2 or COSIN, it will be +inf or -inf. So sort distance was enough. But when use BM25, it will be NAN. Will case sort out of ordered. Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
This commit is contained in:
parent
781df9d0b3
commit
6ff30e8f9e
@ -118,15 +118,17 @@ sort_search_result(milvus::SearchResult& result, bool large_is_better) {
|
||||
|
||||
if (large_is_better) {
|
||||
std::sort(idx.begin(), idx.end(), [&](size_t i, size_t j) {
|
||||
return result.distances_[i] > result.distances_[j] ||
|
||||
(result.seg_offsets_[j] >= 0 &&
|
||||
result.seg_offsets_[j] < 0);
|
||||
if (result.seg_offsets_[j] < 0 || result.seg_offsets_[i] < 0) {
|
||||
return result.seg_offsets_[i] >= 0;
|
||||
}
|
||||
return result.distances_[i] > result.distances_[j];
|
||||
});
|
||||
} else {
|
||||
std::sort(idx.begin(), idx.end(), [&](size_t i, size_t j) {
|
||||
return result.distances_[i] < result.distances_[j] ||
|
||||
(result.seg_offsets_[j] >= 0 &&
|
||||
result.seg_offsets_[j] < 0);
|
||||
if (result.seg_offsets_[j] < 0 || result.seg_offsets_[i] < 0) {
|
||||
return result.seg_offsets_[i] >= 0;
|
||||
}
|
||||
return result.distances_[i] < result.distances_[j];
|
||||
});
|
||||
}
|
||||
for (auto i : idx) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user