Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search query with params tests #2076

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,8 @@ def test_vector_field(modclient):
modclient.hset("b", "v", "aaaabaaa")
modclient.hset("c", "v", "aaaaabaa")

q = Query("*=>[KNN 2 @v $vec]").return_field("__v_score").sort_by("__v_score", True)
query = "*=>[KNN 2 @v $vec]"
q = Query(query).return_field("__v_score").sort_by("__v_score", True).dialect(2)
res = modclient.ft().search(q, query_params={"vec": "aaaaaaaa"})

assert "a" == res.docs[0].id
Expand Down Expand Up @@ -1572,7 +1573,7 @@ def test_text_params(modclient):
modclient.ft().add_document("doc3", name="Carol")

params_dict = {"name1": "Alice", "name2": "Bob"}
q = Query("@name:($name1 | $name2 )")
q = Query("@name:($name1 | $name2 )").dialect(2)
res = modclient.ft().search(q, query_params=params_dict)
assert 2 == res.total
assert "doc1" == res.docs[0].id
Expand All @@ -1589,7 +1590,7 @@ def test_numeric_params(modclient):
modclient.ft().add_document("doc3", numval=103)

params_dict = {"min": 101, "max": 102}
q = Query("@numval:[$min $max]")
q = Query("@numval:[$min $max]").dialect(2)
res = modclient.ft().search(q, query_params=params_dict)

assert 2 == res.total
Expand All @@ -1607,7 +1608,7 @@ def test_geo_params(modclient):
modclient.ft().add_document("doc3", g="29.68746, 34.94882")

params_dict = {"lat": "34.95126", "lon": "29.69465", "radius": 1000, "units": "km"}
q = Query("@g:[$lon $lat $radius $units]")
q = Query("@g:[$lon $lat $radius $units]").dialect(2)
res = modclient.ft().search(q, query_params=params_dict)
assert 3 == res.total
assert "doc1" == res.docs[0].id
Expand Down