diff --git a/client/ann_request.go b/client/ann_request.go index 26f7b61a..19f82823 100644 --- a/client/ann_request.go +++ b/client/ann_request.go @@ -36,13 +36,16 @@ func (r *ANNSearchRequest) WithExpr(expr string) *ANNSearchRequest { return r } -func (r *ANNSearchRequest) getMilvusSearchRequest(collectionInfo *collInfo) (*milvuspb.SearchRequest, error) { +func (r *ANNSearchRequest) getMilvusSearchRequest(collectionInfo *collInfo, opts ...SearchQueryOptionFunc) (*milvuspb.SearchRequest, error) { opt := &SearchQueryOption{ ConsistencyLevel: collectionInfo.ConsistencyLevel, // default } for _, o := range r.options { o(opt) } + for _, o := range opts { + o(opt) + } params := r.searchParam.Params() params[forTuningKey] = opt.ForTuning bs, err := json.Marshal(params) diff --git a/client/client.go b/client/client.go index d3691f78..39a76fc0 100644 --- a/client/client.go +++ b/client/client.go @@ -222,7 +222,7 @@ type Client interface { opts ...ReplicateMessageOption, ) (*entity.MessageInfo, error) - HybridSearch(ctx context.Context, collName string, partitions []string, limit int, outputFields []string, reranker Reranker, subRequests []*ANNSearchRequest) ([]SearchResult, error) + HybridSearch(ctx context.Context, collName string, partitions []string, limit int, outputFields []string, reranker Reranker, subRequests []*ANNSearchRequest, opts ...SearchQueryOptionFunc) ([]SearchResult, error) } // NewClient create a client connected to remote milvus cluster. diff --git a/client/data.go b/client/data.go index 6ee3a28a..e6b526eb 100644 --- a/client/data.go +++ b/client/data.go @@ -36,7 +36,7 @@ const ( groupByKey = `group_by_field` ) -func (c *GrpcClient) HybridSearch(ctx context.Context, collName string, partitions []string, limit int, outputFields []string, reranker Reranker, subRequests []*ANNSearchRequest) ([]SearchResult, error) { +func (c *GrpcClient) HybridSearch(ctx context.Context, collName string, partitions []string, limit int, outputFields []string, reranker Reranker, subRequests []*ANNSearchRequest, opts ...SearchQueryOptionFunc) ([]SearchResult, error) { if c.Service == nil { return nil, ErrClientNotReady } @@ -56,7 +56,7 @@ func (c *GrpcClient) HybridSearch(ctx context.Context, collName string, partitio sReqs := make([]*milvuspb.SearchRequest, 0, len(subRequests)) nq := 0 for _, subRequest := range subRequests { - r, err := subRequest.getMilvusSearchRequest(collInfo) + r, err := subRequest.getMilvusSearchRequest(collInfo, opts...) if err != nil { return nil, err }