mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 03:48:37 +08:00
enhance: Support queryOption WithLimit for milvusclient (#33978)
See also #31293 --------- Signed-off-by: coldWater <254244460@qq.com>
This commit is contained in:
parent
35ea775c14
commit
66710008d6
@ -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)
|
||||
|
@ -31,6 +31,7 @@ const (
|
||||
spAnnsField = `anns_field`
|
||||
spTopK = `topk`
|
||||
spOffset = `offset`
|
||||
spLimit = `limit`
|
||||
spParams = `params`
|
||||
spMetricsType = `metric_type`
|
||||
spRoundDecimal = `round_decimal`
|
||||
@ -197,15 +198,12 @@ type QueryOption interface {
|
||||
}
|
||||
|
||||
type queryOption struct {
|
||||
collectionName string
|
||||
partitionNames []string
|
||||
|
||||
limit int
|
||||
offset int
|
||||
collectionName string
|
||||
partitionNames []string
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user