Skip to content

Commit 19cedab

Browse files
authored
Fix async SEARCH pipeline (#2316)
* fix search async pipeline * newline
1 parent 47b5dd0 commit 19cedab

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

redis/commands/search/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,5 @@ class Pipeline(SearchCommands, redis.client.Pipeline):
167167
"""Pipeline for the module."""
168168

169169

170-
class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline):
170+
class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline, Pipeline):
171171
"""AsyncPipeline for the module."""

tests/test_asyncio/test_search.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from redis.commands.search.query import GeoFilter, NumericFilter, Query
1717
from redis.commands.search.result import Result
1818
from redis.commands.search.suggestion import Suggestion
19-
from tests.conftest import skip_ifmodversion_lt
19+
from tests.conftest import skip_if_redis_enterprise, skip_ifmodversion_lt
2020

2121
WILL_PLAY_TEXT = os.path.abspath(
2222
os.path.join(os.path.dirname(__file__), "testdata", "will_play_text.csv.bz2")
@@ -1043,3 +1043,22 @@ async def test_aggregations_sort_by_and_limit(modclient: redis.Redis):
10431043
res = await modclient.ft().aggregate(req)
10441044
assert len(res.rows) == 1
10451045
assert res.rows[0] == ["t1", "b"]
1046+
1047+
1048+
@pytest.mark.redismod
1049+
@skip_if_redis_enterprise()
1050+
async def test_search_commands_in_pipeline(modclient: redis.Redis):
1051+
p = await modclient.ft().pipeline()
1052+
p.create_index((TextField("txt"),))
1053+
p.add_document("doc1", payload="foo baz", txt="foo bar")
1054+
p.add_document("doc2", txt="foo bar")
1055+
q = Query("foo bar").with_payloads()
1056+
await p.search(q)
1057+
res = await p.execute()
1058+
assert res[:3] == ["OK", "OK", "OK"]
1059+
assert 2 == res[3][0]
1060+
assert "doc1" == res[3][1]
1061+
assert "doc2" == res[3][4]
1062+
assert "foo baz" == res[3][2]
1063+
assert res[3][5] is None
1064+
assert res[3][3] == res[3][6] == ["txt", "foo bar"]

0 commit comments

Comments
 (0)