@@ -1690,6 +1690,132 @@ public async Task Vector_Search_InvalidOffset_ReturnsError()
16901690 }
16911691 }
16921692
1693+ [ Fact ]
1694+ public async Task Vector_Search_LimitSyntax_WorksWithoutPositionalTopK ( )
1695+ {
1696+ var store = new InMemoryKeyValueStore ( ) ;
1697+ var channel = new EmbeddedChannel ( new DredisCommandHandler ( store ) ) ;
1698+
1699+ try
1700+ {
1701+ channel . WriteInbound ( Command ( "VSET" , "emb:a" , "1" , "0" ) ) ;
1702+ channel . RunPendingTasks ( ) ;
1703+ _ = ReadOutbound ( channel ) ;
1704+
1705+ channel . WriteInbound ( Command ( "VSET" , "emb:b" , "0.8" , "0.2" ) ) ;
1706+ channel . RunPendingTasks ( ) ;
1707+ _ = ReadOutbound ( channel ) ;
1708+
1709+ channel . WriteInbound ( Command ( "VSEARCH" , "emb:" , "COSINE" , "LIMIT" , "1" , "1" , "0" ) ) ;
1710+ channel . RunPendingTasks ( ) ;
1711+
1712+ var response = ReadOutbound ( channel ) ;
1713+ var array = Assert . IsType < ArrayRedisMessage > ( response ) ;
1714+ Assert . Equal ( 2 , array . Children . Count ) ;
1715+ Assert . Equal ( "emb:a" , GetBulkString ( Assert . IsType < FullBulkStringRedisMessage > ( array . Children [ 0 ] ) ) ) ;
1716+ }
1717+ finally
1718+ {
1719+ await channel . CloseAsync ( ) ;
1720+ }
1721+ }
1722+
1723+ [ Fact ]
1724+ public async Task Vector_Search_LimitMissing_ReturnsError ( )
1725+ {
1726+ var store = new InMemoryKeyValueStore ( ) ;
1727+ var channel = new EmbeddedChannel ( new DredisCommandHandler ( store ) ) ;
1728+
1729+ try
1730+ {
1731+ channel . WriteInbound ( Command ( "VSEARCH" , "emb:" , "COSINE" , "1" , "0" ) ) ;
1732+ channel . RunPendingTasks ( ) ;
1733+
1734+ var response = ReadOutbound ( channel ) ;
1735+ var error = Assert . IsType < ErrorRedisMessage > ( response ) ;
1736+ Assert . Equal ( "ERR LIMIT is required" , error . Content ) ;
1737+ }
1738+ finally
1739+ {
1740+ await channel . CloseAsync ( ) ;
1741+ }
1742+ }
1743+
1744+ [ Fact ]
1745+ public async Task Vector_Search_OffsetBeforeLimit_ReturnsSyntaxError ( )
1746+ {
1747+ var store = new InMemoryKeyValueStore ( ) ;
1748+ var channel = new EmbeddedChannel ( new DredisCommandHandler ( store ) ) ;
1749+
1750+ try
1751+ {
1752+ channel . WriteInbound ( Command ( "VSET" , "emb:a" , "1" , "0" ) ) ;
1753+ channel . RunPendingTasks ( ) ;
1754+ _ = ReadOutbound ( channel ) ;
1755+
1756+ channel . WriteInbound ( Command ( "VSEARCH" , "emb:" , "COSINE" , "OFFSET" , "1" , "LIMIT" , "1" , "1" , "0" ) ) ;
1757+ channel . RunPendingTasks ( ) ;
1758+
1759+ var response = ReadOutbound ( channel ) ;
1760+ var error = Assert . IsType < ErrorRedisMessage > ( response ) ;
1761+ Assert . Equal ( "ERR LIMIT is required" , error . Content ) ;
1762+ }
1763+ finally
1764+ {
1765+ await channel . CloseAsync ( ) ;
1766+ }
1767+ }
1768+
1769+ [ Fact ]
1770+ public async Task Vector_Search_LimitInPositionalForm_ReturnsSyntaxError ( )
1771+ {
1772+ var store = new InMemoryKeyValueStore ( ) ;
1773+ var channel = new EmbeddedChannel ( new DredisCommandHandler ( store ) ) ;
1774+
1775+ try
1776+ {
1777+ channel . WriteInbound ( Command ( "VSET" , "emb:a" , "1" , "0" ) ) ;
1778+ channel . RunPendingTasks ( ) ;
1779+ _ = ReadOutbound ( channel ) ;
1780+
1781+ channel . WriteInbound ( Command ( "VSEARCH" , "emb:" , "2" , "COSINE" , "LIMIT" , "1" , "1" , "0" ) ) ;
1782+ channel . RunPendingTasks ( ) ;
1783+
1784+ var response = ReadOutbound ( channel ) ;
1785+ var error = Assert . IsType < ErrorRedisMessage > ( response ) ;
1786+ Assert . Equal ( "ERR syntax error" , error . Content ) ;
1787+ }
1788+ finally
1789+ {
1790+ await channel . CloseAsync ( ) ;
1791+ }
1792+ }
1793+
1794+ [ Fact ]
1795+ public async Task Vector_Search_DuplicateOffset_ReturnsSyntaxError ( )
1796+ {
1797+ var store = new InMemoryKeyValueStore ( ) ;
1798+ var channel = new EmbeddedChannel ( new DredisCommandHandler ( store ) ) ;
1799+
1800+ try
1801+ {
1802+ channel . WriteInbound ( Command ( "VSET" , "emb:a" , "1" , "0" ) ) ;
1803+ channel . RunPendingTasks ( ) ;
1804+ _ = ReadOutbound ( channel ) ;
1805+
1806+ channel . WriteInbound ( Command ( "VSEARCH" , "emb:" , "2" , "COSINE" , "OFFSET" , "0" , "OFFSET" , "1" , "1" , "0" ) ) ;
1807+ channel . RunPendingTasks ( ) ;
1808+
1809+ var response = ReadOutbound ( channel ) ;
1810+ var error = Assert . IsType < ErrorRedisMessage > ( response ) ;
1811+ Assert . Equal ( "ERR syntax error" , error . Content ) ;
1812+ }
1813+ finally
1814+ {
1815+ await channel . CloseAsync ( ) ;
1816+ }
1817+ }
1818+
16931819 [ Fact ]
16941820 public async Task Publish_NoSubscribers_ReturnsZero ( )
16951821 {
0 commit comments