From 0c9b1597f275cc87eb577c6c83a83058b102033b Mon Sep 17 00:00:00 2001 From: Xiaoguang Zhu Date: Tue, 9 Sep 2025 14:46:04 +0800 Subject: [PATCH] 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 --- internal/proxy/search_util.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/proxy/search_util.go b/internal/proxy/search_util.go index db8f5e080e..ec1f6b545d 100644 --- a/internal/proxy/search_util.go +++ b/internal/proxy/search_util.go @@ -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 "" }