mirror of https://github.com/milvus-io/milvus.git
fix: empty MetricType (#30216)
issue: #30102 #30225 we should read MetricType from SearchResult, because query node never 1. read metricType from LoadMeta 2. store to collection 3. set SearchRequest.MetricType Signed-off-by: PowderLi <min.li@zilliz.com>pull/30332/head
parent
9512af357b
commit
8fc4ebfa11
|
@ -976,7 +976,7 @@ func buildQueryResp(rowsNum int64, needFields []string, fieldDataList []*schemap
|
|||
}
|
||||
}
|
||||
if scores != nil && int64(len(scores)) > i {
|
||||
row[HTTPReturnDistance] = scores[i]
|
||||
row[HTTPReturnDistance] = scores[i] // only 8 decimal places
|
||||
}
|
||||
queryResp = append(queryResp, row)
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func getCurUserFromContext(ctx context.Context) (string, error) {
|
|||
}
|
||||
authorization, ok := md[strings.ToLower(util.HeaderAuthorize)]
|
||||
if !ok || len(authorization) < 1 {
|
||||
return "", fmt.Errorf("fail to get authorization from the md, authorize:[%s]", util.HeaderAuthorize)
|
||||
return "", fmt.Errorf("fail to get authorization from the md, %s:[token]", strings.ToLower(util.HeaderAuthorize))
|
||||
}
|
||||
token := authorization[0]
|
||||
rawToken, err := crypto.Base64Decode(token)
|
||||
|
|
|
@ -1689,6 +1689,10 @@ func (node *Proxy) GetLoadState(ctx context.Context, request *milvuspb.GetLoadSt
|
|||
|
||||
collectionID, err := globalMetaCache.GetCollectionID(ctx, request.GetDbName(), request.CollectionName)
|
||||
if err != nil {
|
||||
log.Warn("failed to get collection id",
|
||||
zap.String("dbName", request.GetDbName()),
|
||||
zap.String("collectionName", request.CollectionName),
|
||||
zap.Error(err))
|
||||
successResponse.State = commonpb.LoadState_LoadStateNotExist
|
||||
return successResponse, nil
|
||||
}
|
||||
|
|
|
@ -876,7 +876,7 @@ func GetCurUserFromContext(ctx context.Context) (string, error) {
|
|||
}
|
||||
authorization, ok := md[strings.ToLower(util.HeaderAuthorize)]
|
||||
if !ok || len(authorization) < 1 {
|
||||
return "", fmt.Errorf("fail to get authorization from the md, authorize:[%s]", util.HeaderAuthorize)
|
||||
return "", fmt.Errorf("fail to get authorization from the md, %s:[token]", strings.ToLower(util.HeaderAuthorize))
|
||||
}
|
||||
token := authorization[0]
|
||||
rawToken, err := crypto.Base64Decode(token)
|
||||
|
|
|
@ -68,7 +68,7 @@ func (plan *SearchPlan) setMetricType(metricType string) {
|
|||
C.SetMetricType(plan.cSearchPlan, cmt)
|
||||
}
|
||||
|
||||
func (plan *SearchPlan) getMetricType() string {
|
||||
func (plan *SearchPlan) GetMetricType() string {
|
||||
cMetricType := C.GetMetricType(plan.cSearchPlan)
|
||||
defer C.free(unsafe.Pointer(cMetricType))
|
||||
metricType := C.GoString(cMetricType)
|
||||
|
@ -110,7 +110,7 @@ func NewSearchRequest(ctx context.Context, collection *Collection, req *querypb.
|
|||
return nil, err
|
||||
}
|
||||
|
||||
metricTypeInPlan := plan.getMetricType()
|
||||
metricTypeInPlan := plan.GetMetricType()
|
||||
if len(metricType) != 0 && metricType != metricTypeInPlan {
|
||||
plan.delete()
|
||||
return nil, merr.WrapErrParameterInvalid(metricTypeInPlan, metricType, "metric type not match")
|
||||
|
|
|
@ -54,6 +54,10 @@ func ReduceSearchResults(ctx context.Context, results []*internalpb.SearchResult
|
|||
for ch, ts := range r.GetChannelsMvcc() {
|
||||
channelsMvcc[ch] = ts
|
||||
}
|
||||
// shouldn't let new SearchResults.MetricType to be empty, though the req.MetricType is empty
|
||||
if metricType == "" {
|
||||
metricType = r.MetricType
|
||||
}
|
||||
}
|
||||
log := log.Ctx(ctx)
|
||||
|
||||
|
|
|
@ -166,6 +166,9 @@ func (t *SearchTask) Execute() error {
|
|||
}
|
||||
defer segments.DeleteSearchResults(results)
|
||||
|
||||
// plan.MetricType is accurate, though req.MetricType may be empty
|
||||
metricType := searchReq.Plan().GetMetricType()
|
||||
|
||||
if len(results) == 0 {
|
||||
for i := range t.originNqs {
|
||||
var task *SearchTask
|
||||
|
@ -180,7 +183,7 @@ func (t *SearchTask) Execute() error {
|
|||
SourceID: paramtable.GetNodeID(),
|
||||
},
|
||||
Status: merr.Success(),
|
||||
MetricType: req.GetReq().GetMetricType(),
|
||||
MetricType: metricType,
|
||||
NumQueries: t.originNqs[i],
|
||||
TopK: t.originTopks[i],
|
||||
SlicedOffset: 1,
|
||||
|
@ -234,7 +237,7 @@ func (t *SearchTask) Execute() error {
|
|||
SourceID: paramtable.GetNodeID(),
|
||||
},
|
||||
Status: merr.Success(),
|
||||
MetricType: req.GetReq().GetMetricType(),
|
||||
MetricType: metricType,
|
||||
NumQueries: t.originNqs[i],
|
||||
TopK: t.originTopks[i],
|
||||
SlicedBlob: bs,
|
||||
|
|
Loading…
Reference in New Issue