@@ -655,14 +655,26 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
655
655
client .HSet (ctx , "doc2" , "PrimaryKey" , "9::362329" , "CreatedDateTimeUTC" , "1739342399" )
656
656
client .HSet (ctx , "doc3" , "PrimaryKey" , "9::362329" , "CreatedDateTimeUTC" , "1739353199" )
657
657
658
- reducer := redis.FTAggregateReducer {Reducer : redis .SearchCount }
658
+ reducer := redis.FTAggregateReducer {Reducer : redis .SearchCount , As : "perDay" }
659
659
660
660
options := & redis.FTAggregateOptions {
661
- Apply : []redis.FTAggregateApply {{Field : "@CreatedDateTimeUTC /(60*60*24)" , As : "TimestampAsDay" }},
662
- GroupBy : []redis.FTAggregateGroupBy {{Fields : []interface {}{"@TimestampAsDay" }, Reduce : []redis.FTAggregateReducer {reducer }}},
661
+ Apply : []redis.FTAggregateApply {{Field : "floor(@CreatedDateTimeUTC /(60*60*24))" , As : "TimestampAsDay" }},
662
+ GroupBy : []redis.FTAggregateGroupBy {{
663
+ Fields : []interface {}{"@TimestampAsDay" },
664
+ Reduce : []redis.FTAggregateReducer {reducer },
665
+ }},
666
+ SortBy : []redis.FTAggregateSortBy {{
667
+ FieldName : "@perDay" ,
668
+ Desc : true ,
669
+ }},
663
670
}
671
+
664
672
res , err := client .FTAggregateWithArgs (ctx , "idx1" , "*" , options ).Result ()
665
673
Expect (err ).NotTo (HaveOccurred ())
674
+ Expect (res ).ToNot (BeNil ())
675
+ Expect (len (res .Rows )).To (BeEquivalentTo (2 ))
676
+ Expect (res .Rows [0 ].Fields ["perDay" ]).To (BeEquivalentTo ("2" ))
677
+ Expect (res .Rows [1 ].Fields ["perDay" ]).To (BeEquivalentTo ("1" ))
666
678
})
667
679
668
680
It ("should FTAggregate apply" , Label ("search" , "ftaggregate" ), func () {
0 commit comments