Skip to content

Commit

Permalink
enhance: Not pass empty group by field search param (#748)
Browse files Browse the repository at this point in the history
When group by is not set, make sdk not passing empty GroupByField search
param.

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored May 16, 2024
1 parent 785bac6 commit 55cc3b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions client/ann_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ func (r *ANNSearchRequest) getMilvusSearchRequest(collectionInfo *collInfo, opts
return nil, err
}

searchParams := entity.MapKvPairs(map[string]string{
sp := map[string]string{
"anns_field": r.fieldName,
"topk": fmt.Sprintf("%d", r.limit),
"params": string(bs),
"metric_type": string(r.metricType),
"round_decimal": "-1",
ignoreGrowingKey: strconv.FormatBool(opt.IgnoreGrowing),
offsetKey: fmt.Sprintf("%d", opt.Offset),
groupByKey: opt.GroupByField,
})
}
if opt.GroupByField != "" {
sp[groupByKey] = opt.GroupByField
}

searchParams := entity.MapKvPairs(sp)

result := &milvuspb.SearchRequest{
DbName: "",
Expand Down
8 changes: 6 additions & 2 deletions client/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func prepareSearchRequest(collName string, partitions []string,
return nil, err
}

searchParams := entity.MapKvPairs(map[string]string{
spMap := map[string]string{
"anns_field": vectorField,
"topk": fmt.Sprintf("%d", topK),
"params": string(bs),
Expand All @@ -409,7 +409,11 @@ func prepareSearchRequest(collName string, partitions []string,
ignoreGrowingKey: strconv.FormatBool(opt.IgnoreGrowing),
offsetKey: fmt.Sprintf("%d", opt.Offset),
groupByKey: opt.GroupByField,
})
}
if opt.GroupByField != "" {
spMap[groupByKey] = opt.GroupByField
}
searchParams := entity.MapKvPairs(spMap)

req := &milvuspb.SearchRequest{
DbName: "",
Expand Down

0 comments on commit 55cc3b2

Please sign in to comment.