@@ -1902,4 +1902,62 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
1902
1902
Expect (res2 ).ToNot (BeEmpty ())
1903
1903
}).ShouldNot (Panic ())
1904
1904
})
1905
+
1906
+ It ("should FTCreate VECTOR with int8 and uint8 types" , Label ("search" , "ftcreate" ), func () {
1907
+ ctx := context .TODO ()
1908
+
1909
+ // Define INT8 vector field
1910
+ hnswOptionsInt8 := & redis.FTHNSWOptions {
1911
+ Type : "INT8" ,
1912
+ Dim : 2 ,
1913
+ DistanceMetric : "L2" ,
1914
+ }
1915
+
1916
+ // Define UINT8 vector field
1917
+ hnswOptionsUint8 := & redis.FTHNSWOptions {
1918
+ Type : "UINT8" ,
1919
+ Dim : 2 ,
1920
+ DistanceMetric : "L2" ,
1921
+ }
1922
+
1923
+ // Create index with INT8 and UINT8 vector fields
1924
+ val , err := client .FTCreate (ctx , "idx1" ,
1925
+ & redis.FTCreateOptions {},
1926
+ & redis.FieldSchema {FieldName : "int8_vector" , FieldType : redis .SearchFieldTypeVector , VectorArgs : & redis.FTVectorArgs {HNSWOptions : hnswOptionsInt8 }},
1927
+ & redis.FieldSchema {FieldName : "uint8_vector" , FieldType : redis .SearchFieldTypeVector , VectorArgs : & redis.FTVectorArgs {HNSWOptions : hnswOptionsUint8 }},
1928
+ ).Result ()
1929
+
1930
+ Expect (err ).NotTo (HaveOccurred ())
1931
+ Expect (val ).To (BeEquivalentTo ("OK" ))
1932
+ WaitForIndexing (client , "idx1" )
1933
+
1934
+ // Insert vectors in int8 and uint8 format
1935
+ client .HSet (ctx , "doc1" , "int8_vector" , "\x01 \x02 " , "uint8_vector" , "\x01 \x02 " )
1936
+ client .HSet (ctx , "doc2" , "int8_vector" , "\x03 \x04 " , "uint8_vector" , "\x03 \x04 " )
1937
+
1938
+ // Perform KNN search on INT8 vector
1939
+ searchOptionsInt8 := & redis.FTSearchOptions {
1940
+ Return : []redis.FTSearchReturn {{FieldName : "int8_vector" }},
1941
+ SortBy : []redis.FTSearchSortBy {{FieldName : "int8_vector" , Asc : true }},
1942
+ DialectVersion : 2 ,
1943
+ Params : map [string ]interface {}{"vec" : "\x01 \x02 " },
1944
+ }
1945
+
1946
+ resInt8 , err := client .FTSearchWithArgs (ctx , "idx1" , "*=>[KNN 1 @int8_vector $vec]" , searchOptionsInt8 ).Result ()
1947
+ Expect (err ).NotTo (HaveOccurred ())
1948
+ Expect (resInt8 ).To (BeEquivalentTo ("doc1" ))
1949
+
1950
+ // Perform KNN search on UINT8 vector
1951
+ searchOptionsUint8 := & redis.FTSearchOptions {
1952
+ Return : []redis.FTSearchReturn {{FieldName : "uint8_vector" }},
1953
+ SortBy : []redis.FTSearchSortBy {{FieldName : "uint8_vector" , Asc : true }},
1954
+ DialectVersion : 2 ,
1955
+ Params : map [string ]interface {}{"vec" : "\x01 \x02 " },
1956
+ }
1957
+
1958
+ resUint8 , err := client .FTSearchWithArgs (ctx , "idx1" , "*=>[KNN 1 @uint8_vector $vec]" , searchOptionsUint8 ).Result ()
1959
+ Expect (err ).NotTo (HaveOccurred ())
1960
+ Expect (resUint8 ).To (BeEquivalentTo ("doc1" ))
1961
+ })
1962
+
1905
1963
})
0 commit comments