mirror of
https://github.com/redis/go-redis.git
synced 2025-04-16 09:23:06 +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
|
||||
LimitOffset int
|
||||
Limit int
|
||||
CountOnly bool
|
||||
Params map[string]interface{}
|
||||
DialectVersion int
|
||||
}
|
||||
@ -1954,8 +1955,12 @@ func (c cmdable) FTSearchWithArgs(ctx context.Context, index string, query strin
|
||||
args = append(args, "WITHCOUNT")
|
||||
}
|
||||
}
|
||||
if options.LimitOffset >= 0 && options.Limit > 0 {
|
||||
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
|
||||
if options.CountOnly {
|
||||
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 {
|
||||
args = append(args, "PARAMS", len(options.Params)*2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user