enhance: Support queryOption WithLimit for milvusclient (#33978)

See also #31293

---------

Signed-off-by: coldWater <254244460@qq.com>
This commit is contained in:
coldWater 2024-06-21 10:52:02 +08:00 committed by GitHub
parent 35ea775c14
commit 66710008d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 8 deletions

View File

@ -134,7 +134,7 @@ func (c *ColumnJSONBytes) AppendValue(i interface{}) error {
}
v = bs
default:
return fmt.Errorf("expect json compatible type([]byte, struct[}, map], got %T)", i)
return fmt.Errorf("expect json compatible type([]byte, struct, map), got %T", i)
}
}
c.values = append(c.values, v)

View File

@ -31,6 +31,7 @@ const (
spAnnsField = `anns_field`
spTopK = `topk`
spOffset = `offset`
spLimit = `limit`
spParams = `params`
spMetricsType = `metric_type`
spRoundDecimal = `round_decimal`
@ -199,13 +200,10 @@ type QueryOption interface {
type queryOption struct {
collectionName string
partitionNames []string
limit int
offset int
queryParams map[string]string
outputFields []string
consistencyLevel entity.ConsistencyLevel
useDefaultConsistencyLevel bool
ignoreGrowing bool
expr string
}
@ -216,6 +214,7 @@ func (opt *queryOption) Request() *milvuspb.QueryRequest {
OutputFields: opt.outputFields,
Expr: opt.expr,
QueryParams: entity.MapKvPairs(opt.queryParams),
ConsistencyLevel: opt.consistencyLevel.CommonConsistencyLevel(),
}
}
@ -226,7 +225,18 @@ func (opt *queryOption) WithFilter(expr string) *queryOption {
}
func (opt *queryOption) WithOffset(offset int) *queryOption {
opt.offset = offset
if opt.queryParams == nil {
opt.queryParams = make(map[string]string)
}
opt.queryParams[spOffset] = strconv.Itoa(offset)
return opt
}
func (opt *queryOption) WithLimit(limit int) *queryOption {
if opt.queryParams == nil {
opt.queryParams = make(map[string]string)
}
opt.queryParams[spLimit] = strconv.Itoa(limit)
return opt
}