diff options
author | dvora-h <67596500+dvora-h@users.noreply.github.com> | 2022-08-02 17:45:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 17:45:07 +0300 |
commit | 19cedab73a9b7d8e6af2753a1206e79c50ee2d37 (patch) | |
tree | ee9f456631d10a121d347fd50d2b88dd88eee640 | |
parent | 47b5dd081fcea2f14faa6d4ca520f614cc385589 (diff) | |
download | redis-py-19cedab73a9b7d8e6af2753a1206e79c50ee2d37.tar.gz |
Fix async SEARCH pipeline (#2316)
* fix search async pipeline
* newline
-rw-r--r-- | redis/commands/search/__init__.py | 2 | ||||
-rw-r--r-- | tests/test_asyncio/test_search.py | 21 |
2 files changed, 21 insertions, 2 deletions
diff --git a/redis/commands/search/__init__.py b/redis/commands/search/__init__.py index 923711b..70e9c27 100644 --- a/redis/commands/search/__init__.py +++ b/redis/commands/search/__init__.py @@ -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.""" diff --git a/tests/test_asyncio/test_search.py b/tests/test_asyncio/test_search.py index aa52602..ec83e56 100644 --- a/tests/test_asyncio/test_search.py +++ b/tests/test_asyncio/test_search.py @@ -16,7 +16,7 @@ from redis.commands.search.indexDefinition import IndexDefinition 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") @@ -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"] |