@@ -1626,6 +1626,63 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
16261626 Expect (res .Docs [0 ].ID ).To (BeEquivalentTo ("property:1" ))
16271627 Expect (res .Docs [1 ].ID ).To (BeEquivalentTo ("property:2" ))
16281628 })
1629+
1630+ It ("should FTCreate VECTOR with int8 and uint8 types" , Label ("search" , "ftcreate" ), func () {
1631+ SkipBeforeRedisVersion (7.9 , "doesn't work with older redis" )
1632+ // Define INT8 vector field
1633+ hnswOptionsInt8 := & redis.FTHNSWOptions {
1634+ Type : "INT8" ,
1635+ Dim : 2 ,
1636+ DistanceMetric : "L2" ,
1637+ }
1638+
1639+ // Define UINT8 vector field
1640+ hnswOptionsUint8 := & redis.FTHNSWOptions {
1641+ Type : "UINT8" ,
1642+ Dim : 2 ,
1643+ DistanceMetric : "L2" ,
1644+ }
1645+
1646+ // Create index with INT8 and UINT8 vector fields
1647+ val , err := client .FTCreate (ctx , "idx1" ,
1648+ & redis.FTCreateOptions {},
1649+ & redis.FieldSchema {FieldName : "int8_vector" , FieldType : redis .SearchFieldTypeVector , VectorArgs : & redis.FTVectorArgs {HNSWOptions : hnswOptionsInt8 }},
1650+ & redis.FieldSchema {FieldName : "uint8_vector" , FieldType : redis .SearchFieldTypeVector , VectorArgs : & redis.FTVectorArgs {HNSWOptions : hnswOptionsUint8 }},
1651+ ).Result ()
1652+
1653+ Expect (err ).NotTo (HaveOccurred ())
1654+ Expect (val ).To (BeEquivalentTo ("OK" ))
1655+ WaitForIndexing (client , "idx1" )
1656+
1657+ // Insert vectors in int8 and uint8 format
1658+ client .HSet (ctx , "doc1" , "int8_vector" , "\x01 \x02 " , "uint8_vector" , "\x01 \x02 " )
1659+ client .HSet (ctx , "doc2" , "int8_vector" , "\x03 \x04 " , "uint8_vector" , "\x03 \x04 " )
1660+
1661+ // Perform KNN search on INT8 vector
1662+ searchOptionsInt8 := & redis.FTSearchOptions {
1663+ Return : []redis.FTSearchReturn {{FieldName : "int8_vector" }},
1664+ SortBy : []redis.FTSearchSortBy {{FieldName : "int8_vector" , Asc : true }},
1665+ DialectVersion : 2 ,
1666+ Params : map [string ]interface {}{"vec" : "\x01 \x02 " },
1667+ }
1668+
1669+ resInt8 , err := client .FTSearchWithArgs (ctx , "idx1" , "*=>[KNN 1 @int8_vector $vec]" , searchOptionsInt8 ).Result ()
1670+ Expect (err ).NotTo (HaveOccurred ())
1671+ Expect (resInt8 .Docs [0 ].ID ).To (BeEquivalentTo ("doc1" ))
1672+
1673+ // Perform KNN search on UINT8 vector
1674+ searchOptionsUint8 := & redis.FTSearchOptions {
1675+ Return : []redis.FTSearchReturn {{FieldName : "uint8_vector" }},
1676+ SortBy : []redis.FTSearchSortBy {{FieldName : "uint8_vector" , Asc : true }},
1677+ DialectVersion : 2 ,
1678+ Params : map [string ]interface {}{"vec" : "\x01 \x02 " },
1679+ }
1680+
1681+ resUint8 , err := client .FTSearchWithArgs (ctx , "idx1" , "*=>[KNN 1 @uint8_vector $vec]" , searchOptionsUint8 ).Result ()
1682+ Expect (err ).NotTo (HaveOccurred ())
1683+ Expect (resUint8 .Docs [0 ].ID ).To (BeEquivalentTo ("doc1" ))
1684+ })
1685+
16291686})
16301687
16311688func _assert_geosearch_result (result * redis.FTSearchResult , expectedDocIDs []string ) {
0 commit comments