@@ -1066,6 +1066,59 @@ var _ = Describe("RediSearch commands", Label("search"), func() {
1066
1066
Expect (err ).NotTo (HaveOccurred ())
1067
1067
Expect (res .Total ).To (BeEquivalentTo (int64 (1 )))
1068
1068
Expect (res .Docs [0 ].ID ).To (BeEquivalentTo ("resource:1" ))
1069
+
1070
+ client .HSet (ctx , "test:1" , map [string ]interface {}{
1071
+ "uuid" : "3d3586fe-0416-4572-8ce" ,
1072
+
1073
+ "num" : 5 ,
1074
+ })
1075
+
1076
+ // Create the index
1077
+ ftCreateOptions := & redis.FTCreateOptions {
1078
+ Prefix : []interface {}{"test:" },
1079
+ }
1080
+ schema := []* redis.FieldSchema {
1081
+ {
1082
+ FieldName : "uuid" ,
1083
+ FieldType : redis .SearchFieldTypeTag ,
1084
+ },
1085
+ {
1086
+ FieldName : "email" ,
1087
+ FieldType : redis .SearchFieldTypeTag ,
1088
+ },
1089
+ {
1090
+ FieldName : "num" ,
1091
+ FieldType : redis .SearchFieldTypeNumeric ,
1092
+ },
1093
+ }
1094
+
1095
+ val , err = client .FTCreate (ctx , "idx_hash" , ftCreateOptions , schema ... ).Result ()
1096
+ Expect (err ).NotTo (HaveOccurred ())
1097
+ Expect (val ).To (Equal ("OK" ))
1098
+
1099
+ ftSearchOptions := & redis.FTSearchOptions {
1100
+ DialectVersion : 4 ,
1101
+ Params : map [string ]interface {}{
1102
+ "uuid" : "3d3586fe-0416-4572-8ce" ,
1103
+
1104
+ },
1105
+ }
1106
+
1107
+ res , err = client .FTSearchWithArgs (ctx , "idx_hash" , "@uuid:{$uuid}" , ftSearchOptions ).Result ()
1108
+ Expect (err ).NotTo (HaveOccurred ())
1109
+ Expect (res .Docs [0 ].ID ).To (BeEquivalentTo ("test:1" ))
1110
+ Expect (res .Docs [0 ].Fields ["uuid" ]).To (BeEquivalentTo ("3d3586fe-0416-4572-8ce" ))
1111
+
1112
+ res , err = client .FTSearchWithArgs (ctx , "idx_hash" , "@email:{$email}" , ftSearchOptions ).Result ()
1113
+ Expect (err ).NotTo (HaveOccurred ())
1114
+ Expect (res .Docs [0 ].ID ).To (BeEquivalentTo ("test:1" ))
1115
+ Expect (
res .
Docs [
0 ].
Fields [
"email" ]).
To (
BeEquivalentTo (
"[email protected] " ))
1116
+
1117
+ ftSearchOptions .Params = map [string ]interface {}{"num" : 5 }
1118
+ res , err = client .FTSearchWithArgs (ctx , "idx_hash" , "@num:[5]" , ftSearchOptions ).Result ()
1119
+ Expect (err ).NotTo (HaveOccurred ())
1120
+ Expect (res .Docs [0 ].ID ).To (BeEquivalentTo ("test:1" ))
1121
+ Expect (res .Docs [0 ].Fields ["num" ]).To (BeEquivalentTo ("5" ))
1069
1122
})
1070
1123
1071
1124
It ("should FTCreate GeoShape" , Label ("search" , "ftcreate" , "ftsearch" ), func () {
0 commit comments