From 20bb835c65a63bf0729335c261373474b03f353c Mon Sep 17 00:00:00 2001 From: Gao Date: Tue, 17 Dec 2024 11:58:37 +0800 Subject: [PATCH] enhance: support hints param (#860) issue: https://github.com/milvus-io/milvus/issues/37360 Signed-off-by: chasingegg --- client/ann_request.go | 1 + client/data.go | 1 + client/options.go | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/client/ann_request.go b/client/ann_request.go index aa511db3..f8889499 100644 --- a/client/ann_request.go +++ b/client/ann_request.go @@ -61,6 +61,7 @@ func (r *ANNSearchRequest) getMilvusSearchRequest(collectionInfo *collInfo, opts "round_decimal": "-1", ignoreGrowingKey: strconv.FormatBool(opt.IgnoreGrowing), offsetKey: fmt.Sprintf("%d", opt.Offset), + hintsKey: opt.hints, } if opt.GroupByField != "" { sp[groupByKey] = opt.GroupByField diff --git a/client/data.go b/client/data.go index 2232fe81..bee6da15 100644 --- a/client/data.go +++ b/client/data.go @@ -36,6 +36,7 @@ const ( groupByKey = `group_by_field` iteratorKey = `iterator` reduceForBestKey = `reduce_stop_for_best` + hintsKey = `hints` ) func (c *GrpcClient) HybridSearch(ctx context.Context, collName string, partitions []string, limit int, outputFields []string, reranker Reranker, subRequests []*ANNSearchRequest, opts ...SearchQueryOptionFunc) ([]SearchResult, error) { diff --git a/client/options.go b/client/options.go index 3e51ba98..98ca5b2c 100644 --- a/client/options.go +++ b/client/options.go @@ -151,6 +151,7 @@ type SearchQueryOption struct { isIterator bool reduceForBest bool + hints string } // SearchQueryOptionFunc is a function which modifies SearchOption @@ -180,6 +181,12 @@ func WithIgnoreGrowing() SearchQueryOptionFunc { } } +func WithHints(hints string) SearchQueryOptionFunc { + return func(option *SearchQueryOption) { + option.hints = hints + } +} + // WithOffset returns search/query option with offset. func WithOffset(offset int64) SearchQueryOptionFunc { return func(option *SearchQueryOption) {