fix: add pk sort for same distance of hybridsearch (#30901)

#29923

Signed-off-by: luzhang <luzhang@zilliz.com>
Co-authored-by: luzhang <luzhang@zilliz.com>
This commit is contained in:
zhagnlu 2024-03-01 18:09:02 +08:00 committed by GitHub
parent 41f1e6dcad
commit 8b25ecffff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -551,14 +551,30 @@ func rankSearchResultData(ctx context.Context,
continue
}
compareKeys := func(keyI, keyJ interface{}) bool {
switch keyI.(type) {
case int64:
return keyI.(int64) < keyJ.(int64)
case string:
return keyI.(string) < keyJ.(string)
}
return false
}
// sort id by score
var less func(i, j int) bool
if metric.PositivelyRelated(metricType) {
less = func(i, j int) bool {
if idSet[keys[i]] == idSet[keys[j]] {
return compareKeys(keys[i], keys[j])
}
return idSet[keys[i]] > idSet[keys[j]]
}
} else {
less = func(i, j int) bool {
if idSet[keys[i]] == idSet[keys[j]] {
return compareKeys(keys[i], keys[j])
}
return idSet[keys[i]] < idSet[keys[j]]
}
}

View File

@ -11035,7 +11035,6 @@ class TestCollectionHybridSearchValid(TestcaseBase):
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("primary_field", [ct.default_int64_field_name, ct.default_string_field_name])
@pytest.mark.xfail(reason="issue 29923")
def test_hybrid_search_RRFRanker_default_parameter(self, primary_field):
"""
target: test hybrid search with default value to RRFRanker