fix: deduce metric type from non-empty search result (#44222)

issue: https://github.com/milvus-io/milvus/issues/32262

The old implementation always takes metric type from the first sub
result, which may not always be valid. The fixed implementation returns
initialized metric type from sub results.

Signed-off-by: smdsbz <smdsbz@qq.com>
This commit is contained in:
Xiaoguang Zhu 2025-09-09 14:46:04 +08:00 committed by GitHub
parent ecd8fa9b1b
commit 0c9b1597f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -602,9 +602,10 @@ func convertHybridSearchToSearch(req *milvuspb.HybridSearchRequest) *milvuspb.Se
}
func getMetricType(toReduceResults []*internalpb.SearchResults) string {
metricType := ""
if len(toReduceResults) >= 1 {
metricType = toReduceResults[0].GetMetricType()
for _, r := range toReduceResults {
if m := r.GetMetricType(); m != "" {
return m
}
}
return metricType
return ""
}