@@ -1631,3 +1631,48 @@ def test_search_commands_in_pipeline(client):
1631
1631
assert "foo baz" == res [3 ][2 ]
1632
1632
assert res [3 ][5 ] is None
1633
1633
assert res [3 ][3 ] == res [3 ][6 ] == ["txt" , "foo bar" ]
1634
+
1635
+
1636
+ @pytest .mark .redismod
1637
+ @pytest .mark .onlynoncluster
1638
+ @skip_ifmodversion_lt ("2.4.3" , "search" )
1639
+ def test_dialect_config (modclient : redis .Redis ):
1640
+ assert modclient .ft ().config_get ("DEFAULT_DIALECT" ) == {"DEFAULT_DIALECT" : "1" }
1641
+ assert modclient .ft ().config_set ("DEFAULT_DIALECT" , 2 )
1642
+ assert modclient .ft ().config_get ("DEFAULT_DIALECT" ) == {"DEFAULT_DIALECT" : "2" }
1643
+ with pytest .raises (redis .ResponseError ):
1644
+ modclient .ft ().config_set ("DEFAULT_DIALECT" , 0 )
1645
+
1646
+
1647
+ @pytest .mark .redismod
1648
+ @skip_ifmodversion_lt ("2.4.3" , "search" )
1649
+ def test_dialect (modclient : redis .Redis ):
1650
+ modclient .ft ().create_index (
1651
+ (
1652
+ TagField ("title" ),
1653
+ TextField ("t1" ),
1654
+ TextField ("t2" ),
1655
+ NumericField ("num" ),
1656
+ VectorField (
1657
+ "v" , "HNSW" , {"TYPE" : "FLOAT32" , "DIM" : 1 , "DISTANCE_METRIC" : "COSINE" }
1658
+ ),
1659
+ )
1660
+ )
1661
+ modclient .hset ("h" , "t1" , "hello" )
1662
+ with pytest .raises (redis .ResponseError ) as err :
1663
+ modclient .ft ().explain (Query ("(*)" ).dialect (1 ))
1664
+ assert "Syntax error" in str (err )
1665
+ assert "WILDCARD" in modclient .ft ().explain (Query ("(*)" ).dialect (2 ))
1666
+
1667
+ with pytest .raises (redis .ResponseError ) as err :
1668
+ modclient .ft ().explain (Query ("$hello" ).dialect (1 ))
1669
+ assert "Syntax error" in str (err )
1670
+ q = Query ("$hello" ).dialect (2 )
1671
+ expected = "UNION {\n hello\n +hello(expanded)\n }\n "
1672
+ assert expected in modclient .ft ().explain (q , query_params = {"hello" : "hello" })
1673
+
1674
+ expected = "NUMERIC {0.000000 <= @num <= 10.000000}\n "
1675
+ assert expected in modclient .ft ().explain (Query ("@title:(@num:[0 10])" ).dialect (1 ))
1676
+ with pytest .raises (redis .ResponseError ) as err :
1677
+ modclient .ft ().explain (Query ("@title:(@num:[0 10])" ).dialect (2 ))
1678
+ assert "Syntax error" in str (err )
0 commit comments