@@ -1577,6 +1577,62 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
1577
1577
Expect (res .Docs [0 ].ID ).To (BeEquivalentTo ("property:1" ))
1578
1578
Expect (res .Docs [1 ].ID ).To (BeEquivalentTo ("property:2" ))
1579
1579
})
1580
+
1581
+ It ("should FTCreate VECTOR with int8 and uint8 types" , Label ("search" , "ftcreate" ), func () {
1582
+ // Define INT8 vector field
1583
+ hnswOptionsInt8 := & redis.FTHNSWOptions {
1584
+ Type : "INT8" ,
1585
+ Dim : 2 ,
1586
+ DistanceMetric : "L2" ,
1587
+ }
1588
+
1589
+ // Define UINT8 vector field
1590
+ hnswOptionsUint8 := & redis.FTHNSWOptions {
1591
+ Type : "UINT8" ,
1592
+ Dim : 2 ,
1593
+ DistanceMetric : "L2" ,
1594
+ }
1595
+
1596
+ // Create index with INT8 and UINT8 vector fields
1597
+ val , err := client .FTCreate (ctx , "idx1" ,
1598
+ & redis.FTCreateOptions {},
1599
+ & redis.FieldSchema {FieldName : "int8_vector" , FieldType : redis .SearchFieldTypeVector , VectorArgs : & redis.FTVectorArgs {HNSWOptions : hnswOptionsInt8 }},
1600
+ & redis.FieldSchema {FieldName : "uint8_vector" , FieldType : redis .SearchFieldTypeVector , VectorArgs : & redis.FTVectorArgs {HNSWOptions : hnswOptionsUint8 }},
1601
+ ).Result ()
1602
+
1603
+ Expect (err ).NotTo (HaveOccurred ())
1604
+ Expect (val ).To (BeEquivalentTo ("OK" ))
1605
+ WaitForIndexing (client , "idx1" )
1606
+
1607
+ // Insert vectors in int8 and uint8 format
1608
+ client .HSet (ctx , "doc1" , "int8_vector" , "\x01 \x02 " , "uint8_vector" , "\x01 \x02 " )
1609
+ client .HSet (ctx , "doc2" , "int8_vector" , "\x03 \x04 " , "uint8_vector" , "\x03 \x04 " )
1610
+
1611
+ // Perform KNN search on INT8 vector
1612
+ searchOptionsInt8 := & redis.FTSearchOptions {
1613
+ Return : []redis.FTSearchReturn {{FieldName : "int8_vector" }},
1614
+ SortBy : []redis.FTSearchSortBy {{FieldName : "int8_vector" , Asc : true }},
1615
+ DialectVersion : 2 ,
1616
+ Params : map [string ]interface {}{"vec" : "\x01 \x02 " },
1617
+ }
1618
+
1619
+ resInt8 , err := client .FTSearchWithArgs (ctx , "idx1" , "*=>[KNN 1 @int8_vector $vec]" , searchOptionsInt8 ).Result ()
1620
+ Expect (err ).NotTo (HaveOccurred ())
1621
+ Expect (resInt8 .Docs [0 ].ID ).To (BeEquivalentTo ("doc1" ))
1622
+
1623
+ // Perform KNN search on UINT8 vector
1624
+ searchOptionsUint8 := & redis.FTSearchOptions {
1625
+ Return : []redis.FTSearchReturn {{FieldName : "uint8_vector" }},
1626
+ SortBy : []redis.FTSearchSortBy {{FieldName : "uint8_vector" , Asc : true }},
1627
+ DialectVersion : 2 ,
1628
+ Params : map [string ]interface {}{"vec" : "\x01 \x02 " },
1629
+ }
1630
+
1631
+ resUint8 , err := client .FTSearchWithArgs (ctx , "idx1" , "*=>[KNN 1 @uint8_vector $vec]" , searchOptionsUint8 ).Result ()
1632
+ Expect (err ).NotTo (HaveOccurred ())
1633
+ Expect (resUint8 .Docs [0 ].ID ).To (BeEquivalentTo ("doc1" ))
1634
+ })
1635
+
1580
1636
})
1581
1637
1582
1638
func _assert_geosearch_result (result * redis.FTSearchResult , expectedDocIDs []string ) {
@@ -1902,62 +1958,4 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
1902
1958
Expect (res2 ).ToNot (BeEmpty ())
1903
1959
}).ShouldNot (Panic ())
1904
1960
})
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
-
1963
1961
})
0 commit comments