@@ -1143,6 +1143,55 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
11431143 Expect (res .Docs [0 ].Fields ["__v_score" ]).To (BeEquivalentTo ("0" ))
11441144 })
11451145
1146+ It ("should FTCreate VECTOR with dialect 1 " , Label ("search" , "ftcreate" ), func () {
1147+ hnswOptions := & redis.FTHNSWOptions {Type : "FLOAT32" , Dim : 2 , DistanceMetric : "L2" }
1148+ val , err := client .FTCreate (ctx , "idx1" ,
1149+ & redis.FTCreateOptions {},
1150+ & redis.FieldSchema {FieldName : "v" , FieldType : redis .SearchFieldTypeVector , VectorArgs : & redis.FTVectorArgs {HNSWOptions : hnswOptions }}).Result ()
1151+ Expect (err ).NotTo (HaveOccurred ())
1152+ Expect (val ).To (BeEquivalentTo ("OK" ))
1153+ WaitForIndexing (client , "idx1" )
1154+
1155+ client .HSet (ctx , "a" , "v" , "aaaaaaaa" )
1156+ client .HSet (ctx , "b" , "v" , "aaaabaaa" )
1157+ client .HSet (ctx , "c" , "v" , "aaaaabaa" )
1158+
1159+ searchOptions := & redis.FTSearchOptions {
1160+ Return : []redis.FTSearchReturn {{FieldName : "v" }},
1161+ SortBy : []redis.FTSearchSortBy {{FieldName : "v" , Asc : true }},
1162+ Limit : 10 ,
1163+ DialectVersion : 1 ,
1164+ }
1165+ res , err := client .FTSearchWithArgs (ctx , "idx1" , "*" , searchOptions ).Result ()
1166+ Expect (err ).NotTo (HaveOccurred ())
1167+ Expect (res .Docs [0 ].ID ).To (BeEquivalentTo ("a" ))
1168+ Expect (res .Docs [0 ].Fields ["v" ]).To (BeEquivalentTo ("aaaaaaaa" ))
1169+ })
1170+
1171+ It ("should FTCreate VECTOR with default dialect" , Label ("search" , "ftcreate" ), func () {
1172+ hnswOptions := & redis.FTHNSWOptions {Type : "FLOAT32" , Dim : 2 , DistanceMetric : "L2" }
1173+ val , err := client .FTCreate (ctx , "idx1" ,
1174+ & redis.FTCreateOptions {},
1175+ & redis.FieldSchema {FieldName : "v" , FieldType : redis .SearchFieldTypeVector , VectorArgs : & redis.FTVectorArgs {HNSWOptions : hnswOptions }}).Result ()
1176+ Expect (err ).NotTo (HaveOccurred ())
1177+ Expect (val ).To (BeEquivalentTo ("OK" ))
1178+ WaitForIndexing (client , "idx1" )
1179+
1180+ client .HSet (ctx , "a" , "v" , "aaaaaaaa" )
1181+ client .HSet (ctx , "b" , "v" , "aaaabaaa" )
1182+ client .HSet (ctx , "c" , "v" , "aaaaabaa" )
1183+
1184+ searchOptions := & redis.FTSearchOptions {
1185+ Return : []redis.FTSearchReturn {{FieldName : "__v_score" }},
1186+ SortBy : []redis.FTSearchSortBy {{FieldName : "__v_score" , Asc : true }},
1187+ Params : map [string ]interface {}{"vec" : "aaaaaaaa" },
1188+ }
1189+ res , err := client .FTSearchWithArgs (ctx , "idx1" , "*=>[KNN 2 @v $vec]" , searchOptions ).Result ()
1190+ Expect (err ).NotTo (HaveOccurred ())
1191+ Expect (res .Docs [0 ].ID ).To (BeEquivalentTo ("a" ))
1192+ Expect (res .Docs [0 ].Fields ["__v_score" ]).To (BeEquivalentTo ("0" ))
1193+ })
1194+
11461195 It ("should FTCreate and FTSearch text params" , Label ("search" , "ftcreate" , "ftsearch" ), func () {
11471196 val , err := client .FTCreate (ctx , "idx1" , & redis.FTCreateOptions {}, & redis.FieldSchema {FieldName : "name" , FieldType : redis .SearchFieldTypeText }).Result ()
11481197 Expect (err ).NotTo (HaveOccurred ())
0 commit comments