MCPcopy
hub / github.com/redis/redis-py / test_dialect

Method test_dialect

tests/test_search.py:1933–1964  ·  view source on GitHub ↗
(self, client)

Source from the content-addressed store, hash-verified

1931 @pytest.mark.redismod
1932 @skip_ifmodversion_lt("2.4.3", "search")
1933 def test_dialect(self, client):
1934 client.ft().create_index(
1935 (
1936 TagField("title"),
1937 TextField("t1"),
1938 TextField("t2"),
1939 NumericField("num"),
1940 VectorField(
1941 "v",
1942 "HNSW",
1943 {"TYPE": "FLOAT32", "DIM": 1, "DISTANCE_METRIC": "COSINE"},
1944 ),
1945 )
1946 )
1947 client.hset("h", "t1", "hello")
1948 with pytest.raises(redis.ResponseError) as err:
1949 client.ft().explain(Query("(*)").dialect(1))
1950 assert "Syntax error" in str(err.value)
1951 assert "WILDCARD" in client.ft().explain(Query("(*)"))
1952
1953 with pytest.raises(redis.ResponseError) as err:
1954 client.ft().explain(Query("$hello").dialect(1))
1955 assert "Syntax error" in str(err.value)
1956 q = Query("$hello")
1957 expected = "UNION {\n hello\n +hello(expanded)\n}\n"
1958 assert expected in client.ft().explain(q, query_params={"hello": "hello"})
1959
1960 expected = "NUMERIC {0.000000 <= @num <= 10.000000}\n"
1961 assert expected in client.ft().explain(Query("@title:(@num:[0 10])").dialect(1))
1962 with pytest.raises(redis.ResponseError) as err:
1963 client.ft().explain(Query("@title:(@num:[0 10])"))
1964 assert "Syntax error" in str(err.value)
1965
1966
1967class TestAggregations(SearchTestsBase):

Callers

nothing calls this directly

Calls 10

TagFieldClass · 0.90
TextFieldClass · 0.90
NumericFieldClass · 0.90
VectorFieldClass · 0.90
QueryClass · 0.90
create_indexMethod · 0.80
hsetMethod · 0.80
explainMethod · 0.80
ftMethod · 0.45
dialectMethod · 0.45

Tested by

no test coverage detected