enhance: [GoSDK][2.5] Cherry-pick go client 2.5.4 commits and bump version (#42708)

Cherry-pick from master
pr: #41356 #41674

Co-authored-by: Mario Camou <mcamou@users.noreply.github.com>
Co-authored-by: ThreadDao <yufen.zong@zilliz.com>

---------

Signed-off-by: mcamou <mcamou@users.noreply.github.com>
Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
Co-authored-by: Mario Camou <mcamou@users.noreply.github.com>
Co-authored-by: ThreadDao <yufen.zong@zilliz.com>
This commit is contained in:
congqixia 2025-06-13 14:14:36 +08:00 committed by GitHub
parent 2da19b3166
commit 9db6228464
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 24 deletions

View File

@ -18,5 +18,5 @@ package common
const ( const (
// SDKVersion const value for current version // SDKVersion const value for current version
SDKVersion = `2.5.3` SDKVersion = `2.5.4`
) )

View File

@ -84,7 +84,7 @@ func (opt *loadCollectionOption) WithRefresh(isRefresh bool) *loadCollectionOpti
func NewLoadCollectionOption(collectionName string) *loadCollectionOption { func NewLoadCollectionOption(collectionName string) *loadCollectionOption {
return &loadCollectionOption{ return &loadCollectionOption{
collectionName: collectionName, collectionName: collectionName,
replicaNum: 1, // replicaNum: 1, The default value of the replicaNum should be set on the server side
interval: time.Millisecond * 200, interval: time.Millisecond * 200,
} }
} }
@ -156,7 +156,7 @@ func NewLoadPartitionsOption(collectionName string, partitionsNames ...string) *
return &loadPartitionsOption{ return &loadPartitionsOption{
collectionName: collectionName, collectionName: collectionName,
partitionNames: partitionsNames, partitionNames: partitionsNames,
replicaNum: 1, // replicaNum: 1, The default value of the replicaNum should be set on the server side
interval: time.Millisecond * 200, interval: time.Millisecond * 200,
} }
} }

View File

@ -56,7 +56,7 @@ type SearchOption interface {
var _ SearchOption = (*searchOption)(nil) var _ SearchOption = (*searchOption)(nil)
type searchOption struct { type searchOption struct {
annRequest *annRequest annRequest *AnnRequest
collectionName string collectionName string
partitionNames []string partitionNames []string
outputFields []string outputFields []string
@ -64,7 +64,7 @@ type searchOption struct {
useDefaultConsistencyLevel bool useDefaultConsistencyLevel bool
} }
type annRequest struct { type AnnRequest struct {
vectors []entity.Vector vectors []entity.Vector
annField string annField string
@ -81,8 +81,8 @@ type annRequest struct {
templateParams map[string]any templateParams map[string]any
} }
func NewAnnRequest(annField string, limit int, vectors ...entity.Vector) *annRequest { func NewAnnRequest(annField string, limit int, vectors ...entity.Vector) *AnnRequest {
return &annRequest{ return &AnnRequest{
annField: annField, annField: annField,
vectors: vectors, vectors: vectors,
topK: limit, topK: limit,
@ -91,7 +91,7 @@ func NewAnnRequest(annField string, limit int, vectors ...entity.Vector) *annReq
} }
} }
func (r *annRequest) searchRequest() (*milvuspb.SearchRequest, error) { func (r *AnnRequest) searchRequest() (*milvuspb.SearchRequest, error) {
request := &milvuspb.SearchRequest{ request := &milvuspb.SearchRequest{
Nq: int64(len(r.vectors)), Nq: int64(len(r.vectors)),
Dsl: r.expr, Dsl: r.expr,
@ -227,52 +227,52 @@ func slice2TmplValue(val any) (*schemapb.TemplateValue, error) {
}, nil }, nil
} }
func (r *annRequest) WithANNSField(annsField string) *annRequest { func (r *AnnRequest) WithANNSField(annsField string) *AnnRequest {
r.annField = annsField r.annField = annsField
return r return r
} }
func (r *annRequest) WithGroupByField(groupByField string) *annRequest { func (r *AnnRequest) WithGroupByField(groupByField string) *AnnRequest {
r.groupByField = groupByField r.groupByField = groupByField
return r return r
} }
func (r *annRequest) WithGroupSize(groupSize int) *annRequest { func (r *AnnRequest) WithGroupSize(groupSize int) *AnnRequest {
r.groupSize = groupSize r.groupSize = groupSize
return r return r
} }
func (r *annRequest) WithStrictGroupSize(strictGroupSize bool) *annRequest { func (r *AnnRequest) WithStrictGroupSize(strictGroupSize bool) *AnnRequest {
r.strictGroupSize = strictGroupSize r.strictGroupSize = strictGroupSize
return r return r
} }
func (r *annRequest) WithSearchParam(key, value string) *annRequest { func (r *AnnRequest) WithSearchParam(key, value string) *AnnRequest {
r.searchParam[key] = value r.searchParam[key] = value
return r return r
} }
func (r *annRequest) WithAnnParam(ap index.AnnParam) *annRequest { func (r *AnnRequest) WithAnnParam(ap index.AnnParam) *AnnRequest {
r.annParam = ap r.annParam = ap
return r return r
} }
func (r *annRequest) WithFilter(expr string) *annRequest { func (r *AnnRequest) WithFilter(expr string) *AnnRequest {
r.expr = expr r.expr = expr
return r return r
} }
func (r *annRequest) WithTemplateParam(key string, val any) *annRequest { func (r *AnnRequest) WithTemplateParam(key string, val any) *AnnRequest {
r.templateParams[key] = val r.templateParams[key] = val
return r return r
} }
func (r *annRequest) WithOffset(offset int) *annRequest { func (r *AnnRequest) WithOffset(offset int) *AnnRequest {
r.offset = offset r.offset = offset
return r return r
} }
func (r *annRequest) WithIgnoreGrowing(ignoreGrowing bool) *annRequest { func (r *AnnRequest) WithIgnoreGrowing(ignoreGrowing bool) *AnnRequest {
r.ignoreGrowing = ignoreGrowing r.ignoreGrowing = ignoreGrowing
return r return r
} }
@ -422,7 +422,7 @@ type hybridSearchOption struct {
collectionName string collectionName string
partitionNames []string partitionNames []string
reqs []*annRequest reqs []*AnnRequest
outputFields []string outputFields []string
useDefaultConsistency bool useDefaultConsistency bool
@ -494,7 +494,7 @@ func (opt *hybridSearchOption) HybridRequest() (*milvuspb.HybridSearchRequest, e
}, nil }, nil
} }
func NewHybridSearchOption(collectionName string, limit int, annRequests ...*annRequest) *hybridSearchOption { func NewHybridSearchOption(collectionName string, limit int, annRequests ...*AnnRequest) *hybridSearchOption {
return &hybridSearchOption{ return &hybridSearchOption{
collectionName: collectionName, collectionName: collectionName,
reqs: annRequests, reqs: annRequests,

View File

@ -358,8 +358,15 @@ func TestDatabasePropertiesRgReplicas(t *testing.T) {
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
_, err = mc.LoadCollection(ctx, client.NewLoadCollectionOption(schema.CollectionName)) // When load does not specify parameters, rg and replica Properties take effect
common.CheckErr(t, err, true) _, errLoad := mc.LoadCollection(ctx, client.NewLoadCollectionOption(schema.CollectionName))
common.CheckErr(t, errLoad, false, "resource group not found", "service resource insufficient")
// actually load with default rg, rg1 not existed
taskLoad, errLoad := mc.LoadCollection(ctx, client.NewLoadCollectionOption(schema.CollectionName).WithReplica(1))
common.CheckErr(t, errLoad, true)
errLoad = taskLoad.Await(ctx)
common.CheckErr(t, errLoad, true)
_, err = mc.Query(ctx, client.NewQueryOption(schema.CollectionName).WithLimit(10)) _, err = mc.Query(ctx, client.NewQueryOption(schema.CollectionName).WithLimit(10))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)