redis-py
redis-py copied to clipboard
No results when using query_params
Version: 4.5.1 and redis-stack 6.2.6 (latest) via docker
Platform: Ubuntu 22.04 LTS
Description: Weird behaviour when using query_params
Creating, adding, indexes works fine. Queries also work fine via redis-cli however translating them to python and using query_params gives me no results.
e.g. this doesn't work:
items_query = (
Query(r"@item_id:{$item_ids}")
.sort_by("created_time").dialect(2)
)
results = await aioredis_conn.ft("items_idx").search(
items_query,
query_params={
"item_ids": "|".join(item_ids),
},
) # type: ignore
This works:
items_query = (
Query(r"@item_id:{"+"|".join(item_ids)+"}")
.sort_by("created_time").dialect(2)
)
results = await aioredis_conn.ft("items_idx").search(
items_query,
) # type: ignore
Is there a way to see the complete query that gets sent ? I assumed the "|" is causing an issue in the query params but I don't really see how as it works when using it directly and even in the below case.
this works fine (this code is somewhere else but is similar):
query = (
Query(r"@uuid:{$uuid} @item_id:{$item_ids}")
.return_fields("item_id", "state")
.dialect(2)
) # type:ignore
result = await aioredis_conn.ft("another_idx").search(
query,
query_params={
"uuid": user_uuid,
"item_ids": "|".join(item_list),
},
) # type: ignore
All of the params are TAGs.
How do you even begin to debug these kinds of issues ? (explain doesn't seem to work in python for the above)