Skip to content

Commit

Permalink
Fix async SEARCH pipeline (#2316)
Browse files Browse the repository at this point in the history
* fix search async pipeline

* newline
  • Loading branch information
dvora-h authored Aug 2, 2022
1 parent 47b5dd0 commit 19cedab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion redis/commands/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,5 @@ class Pipeline(SearchCommands, redis.client.Pipeline):
"""Pipeline for the module."""


class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline):
class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline, Pipeline):
"""AsyncPipeline for the module."""
21 changes: 20 additions & 1 deletion tests/test_asyncio/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from redis.commands.search.query import GeoFilter, NumericFilter, Query
from redis.commands.search.result import Result
from redis.commands.search.suggestion import Suggestion
from tests.conftest import skip_ifmodversion_lt
from tests.conftest import skip_if_redis_enterprise, skip_ifmodversion_lt

WILL_PLAY_TEXT = os.path.abspath(
os.path.join(os.path.dirname(__file__), "testdata", "will_play_text.csv.bz2")
Expand Down Expand Up @@ -1043,3 +1043,22 @@ async def test_aggregations_sort_by_and_limit(modclient: redis.Redis):
res = await modclient.ft().aggregate(req)
assert len(res.rows) == 1
assert res.rows[0] == ["t1", "b"]


@pytest.mark.redismod
@skip_if_redis_enterprise()
async def test_search_commands_in_pipeline(modclient: redis.Redis):
p = await modclient.ft().pipeline()
p.create_index((TextField("txt"),))
p.add_document("doc1", payload="foo baz", txt="foo bar")
p.add_document("doc2", txt="foo bar")
q = Query("foo bar").with_payloads()
await p.search(q)
res = await p.execute()
assert res[:3] == ["OK", "OK", "OK"]
assert 2 == res[3][0]
assert "doc1" == res[3][1]
assert "doc2" == res[3][4]
assert "foo baz" == res[3][2]
assert res[3][5] is None
assert res[3][3] == res[3][6] == ["txt", "foo bar"]

0 comments on commit 19cedab

Please sign in to comment.