mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
use limit when limitoffset is zero (#3275)
This commit is contained in:
parent
9db1286414
commit
196fc9b21a
@ -574,11 +574,8 @@ func FTAggregateQuery(query string, options *FTAggregateOptions) AggregateQuery
|
|||||||
if options.SortByMax > 0 {
|
if options.SortByMax > 0 {
|
||||||
queryArgs = append(queryArgs, "MAX", options.SortByMax)
|
queryArgs = append(queryArgs, "MAX", options.SortByMax)
|
||||||
}
|
}
|
||||||
if options.LimitOffset > 0 {
|
if options.LimitOffset >= 0 && options.Limit > 0 {
|
||||||
queryArgs = append(queryArgs, "LIMIT", options.LimitOffset)
|
queryArgs = append(queryArgs, "LIMIT", options.LimitOffset, options.Limit)
|
||||||
}
|
|
||||||
if options.Limit > 0 {
|
|
||||||
queryArgs = append(queryArgs, options.Limit)
|
|
||||||
}
|
}
|
||||||
if options.Filter != "" {
|
if options.Filter != "" {
|
||||||
queryArgs = append(queryArgs, "FILTER", options.Filter)
|
queryArgs = append(queryArgs, "FILTER", options.Filter)
|
||||||
@ -773,11 +770,8 @@ func (c cmdable) FTAggregateWithArgs(ctx context.Context, index string, query st
|
|||||||
if options.SortByMax > 0 {
|
if options.SortByMax > 0 {
|
||||||
args = append(args, "MAX", options.SortByMax)
|
args = append(args, "MAX", options.SortByMax)
|
||||||
}
|
}
|
||||||
if options.LimitOffset > 0 {
|
if options.LimitOffset >= 0 && options.Limit > 0 {
|
||||||
args = append(args, "LIMIT", options.LimitOffset)
|
args = append(args, "LIMIT", options.LimitOffset, options.Limit)
|
||||||
}
|
|
||||||
if options.Limit > 0 {
|
|
||||||
args = append(args, options.Limit)
|
|
||||||
}
|
}
|
||||||
if options.Filter != "" {
|
if options.Filter != "" {
|
||||||
args = append(args, "FILTER", options.Filter)
|
args = append(args, "FILTER", options.Filter)
|
||||||
|
@ -616,6 +616,11 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
|
|||||||
res, err = client.FTAggregateWithArgs(ctx, "idx1", "*", options).Result()
|
res, err = client.FTAggregateWithArgs(ctx, "idx1", "*", options).Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(res.Rows[0].Fields["t1"]).To(BeEquivalentTo("b"))
|
Expect(res.Rows[0].Fields["t1"]).To(BeEquivalentTo("b"))
|
||||||
|
|
||||||
|
options = &redis.FTAggregateOptions{SortBy: []redis.FTAggregateSortBy{{FieldName: "@t1"}}, Limit: 1, LimitOffset: 0}
|
||||||
|
res, err = client.FTAggregateWithArgs(ctx, "idx1", "*", options).Result()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(res.Rows[0].Fields["t1"]).To(BeEquivalentTo("a"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should FTAggregate load ", Label("search", "ftaggregate"), func() {
|
It("should FTAggregate load ", Label("search", "ftaggregate"), func() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user