mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
Fix Limit argument and add CountOnly argument
This commit is contained in:
parent
46484324a5
commit
639b45ebf5
@ -320,6 +320,7 @@ type FTSearchOptions struct {
|
|||||||
SortByWithCount bool
|
SortByWithCount bool
|
||||||
LimitOffset int
|
LimitOffset int
|
||||||
Limit int
|
Limit int
|
||||||
|
CountOnly bool
|
||||||
Params map[string]interface{}
|
Params map[string]interface{}
|
||||||
DialectVersion int
|
DialectVersion int
|
||||||
}
|
}
|
||||||
@ -1954,8 +1955,12 @@ func (c cmdable) FTSearchWithArgs(ctx context.Context, index string, query strin
|
|||||||
args = append(args, "WITHCOUNT")
|
args = append(args, "WITHCOUNT")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if options.LimitOffset >= 0 && options.Limit > 0 {
|
if options.CountOnly {
|
||||||
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
|
args = append(args, "LIMIT", 0, 0)
|
||||||
|
} else {
|
||||||
|
if options.LimitOffset >= 0 && options.Limit > 0 || options.LimitOffset > 0 && options.Limit == 0 {
|
||||||
|
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if options.Params != nil {
|
if options.Params != nil {
|
||||||
args = append(args, "PARAMS", len(options.Params)*2)
|
args = append(args, "PARAMS", len(options.Params)*2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user