Skip to content

Commit

Permalink
enhance: Support queryOption WithLimit for milvusclient (#33978)
Browse files Browse the repository at this point in the history
See also #31293

---------

Signed-off-by: coldWater <[email protected]>
  • Loading branch information
forsaken628 authored Jun 21, 2024
1 parent 35ea775 commit 6671000
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/column/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 17 additions & 7 deletions client/read_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
spAnnsField = `anns_field`
spTopK = `topk`
spOffset = `offset`
spLimit = `limit`
spParams = `params`
spMetricsType = `metric_type`
spRoundDecimal = `round_decimal`
Expand Down Expand Up @@ -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
}

Expand All @@ -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(),
}
}
Expand All @@ -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
}

Expand Down

0 comments on commit 6671000

Please sign in to comment.