@@ -805,6 +805,73 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
805
805
}
806
806
})
807
807
808
+ It ("should return only the base query when options is nil" , Label ("search" , "ftaggregate" ), func () {
809
+ args := redis .FTAggregateQuery ("testQuery" , nil )
810
+ Expect (args ).To (Equal (redis.AggregateQuery {"testQuery" }))
811
+ })
812
+
813
+ It ("should include VERBATIM and SCORER when options are set" , Label ("search" , "ftaggregate" ), func () {
814
+ options := & redis.FTAggregateOptions {
815
+ Verbatim : true ,
816
+ Scorer : "BM25" ,
817
+ }
818
+ args := redis .FTAggregateQuery ("testQuery" , options )
819
+ Expect (args [0 ]).To (Equal ("testQuery" ))
820
+ Expect (args ).To (ContainElement ("VERBATIM" ))
821
+ Expect (args ).To (ContainElement ("SCORER" ))
822
+ Expect (args ).To (ContainElement ("BM25" ))
823
+ })
824
+
825
+ It ("should include ADDSCORES when AddScores is true" , Label ("search" , "ftaggregate" ), func () {
826
+ options := & redis.FTAggregateOptions {
827
+ AddScores : true ,
828
+ }
829
+ args := redis .FTAggregateQuery ("q" , options )
830
+ Expect (args ).To (ContainElement ("ADDSCORES" ))
831
+ })
832
+
833
+ It ("should include LOADALL when LoadAll is true" , Label ("search" , "ftaggregate" ), func () {
834
+ options := & redis.FTAggregateOptions {
835
+ LoadAll : true ,
836
+ }
837
+ args := redis .FTAggregateQuery ("q" , options )
838
+ Expect (args ).To (ContainElement ("LOAD" ))
839
+ Expect (args ).To (ContainElement ("*" ))
840
+ })
841
+
842
+ It ("should include LOAD when Load is provided" , Label ("search" , "ftaggregate" ), func () {
843
+ options := & redis.FTAggregateOptions {
844
+ Load : []redis.FTAggregateLoad {
845
+ {Field : "field1" , As : "alias1" },
846
+ {Field : "field2" },
847
+ },
848
+ }
849
+ args := redis .FTAggregateQuery ("q" , options )
850
+ // Verify LOAD options related arguments
851
+ Expect (args ).To (ContainElement ("LOAD" ))
852
+ // Check that field names and aliases are present
853
+ Expect (args ).To (ContainElement ("field1" ))
854
+ Expect (args ).To (ContainElement ("alias1" ))
855
+ Expect (args ).To (ContainElement ("field2" ))
856
+ })
857
+
858
+ It ("should include TIMEOUT when Timeout > 0" , Label ("search" , "ftaggregate" ), func () {
859
+ options := & redis.FTAggregateOptions {
860
+ Timeout : 500 ,
861
+ }
862
+ args := redis .FTAggregateQuery ("q" , options )
863
+ Expect (args ).To (ContainElement ("TIMEOUT" ))
864
+ found := false
865
+ for i , a := range args {
866
+ if fmt .Sprintf ("%s" , a ) == "TIMEOUT" {
867
+ Expect (fmt .Sprintf ("%d" , args [i + 1 ])).To (Equal ("500" ))
868
+ found = true
869
+ break
870
+ }
871
+ }
872
+ Expect (found ).To (BeTrue ())
873
+ })
874
+
808
875
It ("should FTSearch SkipInitialScan" , Label ("search" , "ftsearch" ), func () {
809
876
client .HSet (ctx , "doc1" , "foo" , "bar" )
810
877
0 commit comments