Skip to content

Commit 639b45e

Browse files
committed
Fix Limit argument and add CountOnly argument
1 parent 4648432 commit 639b45e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

search_commands.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ type FTSearchOptions struct {
320320
SortByWithCount bool
321321
LimitOffset int
322322
Limit int
323+
CountOnly bool
323324
Params map[string]interface{}
324325
DialectVersion int
325326
}
@@ -1954,8 +1955,12 @@ func (c cmdable) FTSearchWithArgs(ctx context.Context, index string, query strin
19541955
args = append(args, "WITHCOUNT")
19551956
}
19561957
}
1957-
if options.LimitOffset >= 0 && options.Limit > 0 {
1958-
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
1958+
if options.CountOnly {
1959+
args = append(args, "LIMIT", 0, 0)
1960+
} else {
1961+
if options.LimitOffset >= 0 && options.Limit > 0 || options.LimitOffset > 0 && options.Limit == 0 {
1962+
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
1963+
}
19591964
}
19601965
if options.Params != nil {
19611966
args = append(args, "PARAMS", len(options.Params)*2)

0 commit comments

Comments
 (0)