Skip to content

Commit

Permalink
enhance: support hints param (#860)
Browse files Browse the repository at this point in the history
issue: milvus-io/milvus#37360

Signed-off-by: chasingegg <[email protected]>
  • Loading branch information
chasingegg authored Dec 17, 2024
1 parent 532d62a commit 20bb835
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/ann_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions client/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions client/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type SearchQueryOption struct {

isIterator bool
reduceForBest bool
hints string
}

// SearchQueryOptionFunc is a function which modifies SearchOption
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 20bb835

Please sign in to comment.