Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: Support offset in hybrid search outer request #727

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion client/ann_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions client/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
Loading