We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
RediSearch: search command doesn't support asyncio Pipeline
The RediSearch search command returns an instance of the `Result` class except when the Redis client is a `Pipeline` because `Pipeline` returns itself instead of a result when you execute a command. There's code that checks for this in both the `SearchCommands` and `AsyncSearchCommands` classes:
https://github.com/redis/redis-py/blob/4b0543d567aef36ac467ce495d831a24575d8d5b/redis/commands/search/commands.py#L414
https://github.com/redis/redis-py/blob/4b0543d567aef36ac467ce495d831a24575d8d5b/redis/commands/search/commands.py#L883
However, this check doesn't work if the `Pipeline` is from the `redis.asyncio.client` module. The following modification should fix the issue:
```python
from redis.client import Pipeline
from redis.asyncio.client import Pipeline as AsyncPipeline
...
        if isinstance(res, Pipeline) or isinstance(res, AsyncPipeline):
            return res
...
```
I'm not sure if it makes sense to check for both `Pipeline` types or if the `SearchCommands` class should check for just `Pipeline` and the `AsyncSearchCommands` class should check for just `AsyncPipeline`. Let me know and I can make a PR. Or feel free to make the changes yourself if that's easier. Thanks!

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `redis/commands/search/__init__.py`
Content:
```
1 import redis
2 
3 from ...asyncio.client import Pipeline as AsyncioPipeline
4 from .commands import AsyncSearchCommands, SearchCommands
5 
6 
7 class Search(SearchCommands):
8     """
9     Create a client for talking to search.
10     It abstracts the API of the module and lets you just use the engine.
11     """
12 
13     class BatchIndexer:
14         """
15         A batch indexer allows you to automatically batch
16         document indexing in pipelines, flushing it every N documents.
17         """
18 
19         def __init__(self, client, chunk_size=1000):
20 
21             self.client = client
22             self.execute_command = client.execute_command
23             self._pipeline = client.pipeline(transaction=False, shard_hint=None)
24             self.total = 0
25             self.chunk_size = chunk_size
26             self.current_chunk = 0
27 
28         def __del__(self):
29             if self.current_chunk:
30                 self.commit()
31 
32         def add_document(
33             self,
34             doc_id,
35             nosave=False,
36             score=1.0,
37             payload=None,
38             replace=False,
39             partial=False,
40             no_create=False,
41             **fields,
42         ):
43             """
44             Add a document to the batch query
45             """
46             self.client._add_document(
47                 doc_id,
48                 conn=self._pipeline,
49                 nosave=nosave,
50                 score=score,
51                 payload=payload,
52                 replace=replace,
53                 partial=partial,
54                 no_create=no_create,
55                 **fields,
56             )
57             self.current_chunk += 1
58             self.total += 1
59             if self.current_chunk >= self.chunk_size:
60                 self.commit()
61 
62         def add_document_hash(self, doc_id, score=1.0, replace=False):
63             """
64             Add a hash to the batch query
65             """
66             self.client._add_document_hash(
67                 doc_id, conn=self._pipeline, score=score, replace=replace
68             )
69             self.current_chunk += 1
70             self.total += 1
71             if self.current_chunk >= self.chunk_size:
72                 self.commit()
73 
74         def commit(self):
75             """
76             Manually commit and flush the batch indexing query
77             """
78             self._pipeline.execute()
79             self.current_chunk = 0
80 
81     def __init__(self, client, index_name="idx"):
82         """
83         Create a new Client for the given index_name.
84         The default name is `idx`
85 
86         If conn is not None, we employ an already existing redis connection
87         """
88         self.MODULE_CALLBACKS = {}
89         self.client = client
90         self.index_name = index_name
91         self.execute_command = client.execute_command
92         self._pipeline = client.pipeline
93 
94     def pipeline(self, transaction=True, shard_hint=None):
95         """Creates a pipeline for the SEARCH module, that can be used for executing
96         SEARCH commands, as well as classic core commands.
97         """
98         p = Pipeline(
99             connection_pool=self.client.connection_pool,
100             response_callbacks=self.MODULE_CALLBACKS,
101             transaction=transaction,
102             shard_hint=shard_hint,
103         )
104         p.index_name = self.index_name
105         return p
106 
107 
108 class AsyncSearch(Search, AsyncSearchCommands):
109     class BatchIndexer(Search.BatchIndexer):
110         """
111         A batch indexer allows you to automatically batch
112         document indexing in pipelines, flushing it every N documents.
113         """
114 
115         async def add_document(
116             self,
117             doc_id,
118             nosave=False,
119             score=1.0,
120             payload=None,
121             replace=False,
122             partial=False,
123             no_create=False,
124             **fields,
125         ):
126             """
127             Add a document to the batch query
128             """
129             self.client._add_document(
130                 doc_id,
131                 conn=self._pipeline,
132                 nosave=nosave,
133                 score=score,
134                 payload=payload,
135                 replace=replace,
136                 partial=partial,
137                 no_create=no_create,
138                 **fields,
139             )
140             self.current_chunk += 1
141             self.total += 1
142             if self.current_chunk >= self.chunk_size:
143                 await self.commit()
144 
145         async def commit(self):
146             """
147             Manually commit and flush the batch indexing query
148             """
149             await self._pipeline.execute()
150             self.current_chunk = 0
151 
152     def pipeline(self, transaction=True, shard_hint=None):
153         """Creates a pipeline for the SEARCH module, that can be used for executing
154         SEARCH commands, as well as classic core commands.
155         """
156         p = AsyncPipeline(
157             connection_pool=self.client.connection_pool,
158             response_callbacks=self.MODULE_CALLBACKS,
159             transaction=transaction,
160             shard_hint=shard_hint,
161         )
162         p.index_name = self.index_name
163         return p
164 
165 
166 class Pipeline(SearchCommands, redis.client.Pipeline):
167     """Pipeline for the module."""
168 
169 
170 class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline):
171     """AsyncPipeline for the module."""
172
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/redis/commands/search/__init__.py b/redis/commands/search/__init__.py
--- a/redis/commands/search/__init__.py
+++ b/redis/commands/search/__init__.py
@@ -167,5 +167,5 @@
     """Pipeline for the module."""
 
 
-class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline):
+class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline, Pipeline):
     """AsyncPipeline for the module."""

{"golden_diff": "diff --git a/redis/commands/search/__init__.py b/redis/commands/search/__init__.py\n--- a/redis/commands/search/__init__.py\n+++ b/redis/commands/search/__init__.py\n@@ -167,5 +167,5 @@\n     \"\"\"Pipeline for the module.\"\"\"\n \n \n-class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline):\n+class AsyncPipeline(AsyncSearchCommands, AsyncioPipeline, Pipeline):\n     \"\"\"AsyncPipeline for the module.\"\"\"\n", "issue": "RediSearch: search command doesn't support asyncio Pipeline\nThe RediSearch search command returns an instance of the `Result` class except when the Redis client is a `Pipeline` because `Pipeline` returns itself instead of a result when you execute a command. There's code that checks for this in both the `SearchCommands` and `AsyncSearchCommands` classes:\r\nhttps://github.com/redis/redis-py/blob/4b0543d567aef36ac467ce495d831a24575d8d5b/redis/commands/search/commands.py#L414\r\nhttps://github.com/redis/redis-py/blob/4b0543d567aef36ac467ce495d831a24575d8d5b/redis/commands/search/commands.py#L883\r\nHowever, this check doesn't work if the `Pipeline` is from the `redis.asyncio.client` module. The following modification should fix the issue:\r\n```python\r\nfrom redis.client import Pipeline\r\nfrom redis.asyncio.client import Pipeline as AsyncPipeline\r\n...\r\n        if isinstance(res, Pipeline) or isinstance(res, AsyncPipeline):\r\n            return res\r\n...\r\n```\r\nI'm not sure if it makes sense to check for both `Pipeline` types or if the `SearchCommands` class should check for just `Pipeline` and the `AsyncSearchCommands` class should check for just `AsyncPipeline`. Let me know and I can make a PR. Or feel free to make the changes yourself if that's easier. Thanks!\n", "before_files": [{"content": "import redis\n\nfrom ...asyncio.client import Pipeline as AsyncioPipeline\nfrom .commands import AsyncSearchCommands, SearchCommands\n\n\nclass Search(SearchCommands):\n    \"\"\"\n    Create a client for talking to search.\n    It abstracts the API of the module and lets you just use the engine.\n    \"\"\"\n\n    class BatchIndexer:\n        \"\"\"\n        A batch indexer allows you to automatically batch\n        document indexing in pipelines, flushing it every N documents.\n        \"\"\"\n\n        def __init__(self, client, chunk_size=1000):\n\n            self.client = client\n            self.execute_command = client.execute_command\n            self._pipeline = client.pipeline(transaction=False, shard_hint=None)\n            self.total = 0\n            self.chunk_size = chunk_size\n            self.current_chunk = 0\n\n        def __del__(self):\n            if self.current_chunk:\n                self.commit()\n\n        def add_document(\n            self,\n            doc_id,\n            nosave=False,\n            score=1.0,\n            payload=None,\n            replace=False,\n            partial=False,\n            no_create=False,\n            **fields,\n        ):\n            \"\"\"\n            Add a document to the batch query\n            \"\"\"\n            self.client._add_document(\n                doc_id,\n                conn=self._pipeline,\n                nosave=nosave,\n                score=score,\n                payload=payload,\n                replace=replace,\n                partial=partial,\n                no_create=no_create,\n                **fields,\n            )\n            self.current_chunk += 1\n            self.total += 1\n            if self.current_chunk >= self.chunk_size:\n                self.commit()\n\n        def add_document_hash(self, doc_id, score=1.0, replace=False):\n            \"\"\"\n            Add a hash to the batch query\n            \"\"\"\n            self.client._add_document_hash(\n                doc_id, conn=self._pipeline, score=score, replace=replace\n            )\n            self.current_chunk += 1\n            self.total += 1\n            if self.current_chunk >= self.chunk_size:\n                self.commit()\n\n        def commit(self):\n            \"\"\"\n            Manually commit and flush the batch indexing query\n            \"\"\"\n            self._pipeline.execute()\n            self.current_chunk = 0\n\n    def __init__(self, client, index_name=\"idx\"):\n        \"\"\"\n        Create a new Client for the given index_name.\n        The default name is `idx`\n\n        If conn is not None, we employ an already existing redis connection\n        \"\"\"\n        self.MODULE_CALLBACKS = {}\n        self.client = client\n        self.index_name = index_name\n        self.execute_command = client.execute_command\n        self._pipeline = client.pipeline\n\n    def pipeline(self, transaction=True, shard_hint=None):\n        \"\"\"Creates a pipeline for the SEARCH module, that can be used for executing\n        SEARCH commands, as well as classic core commands.\n        \"\"\"\n        p = Pipeline(\n            connection_pool=self.client.connection_pool,\n            response_callbacks=self.MODULE_CALLBACKS,\n            transaction=transaction,\n            shard_hint=shard_hint,\n        )\n        p.index_name = self.index_name\n        return p\n\n\nclass AsyncSearch(Search, AsyncSearchCommands):\n    class BatchIndexer(Search.BatchIndexer):\n        \"\"\"\n        A batch indexer allows you to automatically batch\n        document indexing in pipelines, flushing it every N documents.\n        \"\"\"\n\n        async def add_document(\n            self,\n            doc_id,\n            nosave=False,\n            score=1.0,\n            payload=None,\n            replace=False,\n            partial=False,\n            no_create=False,\n            **fields,\n        ):\n            \"\"\"\n            Add a document to the batch query\n            \"\"\"\n            self.client._add_document(\n                doc_id,\n                conn=self._pipeline,\n                nosave=nosave,\n                score=score,\n                payload=payload,\n                replace=replace,\n                partial=partial,\n                no_create=no_create,\n                **fields,\n            )\n            self.current_chunk += 1\n            self.total += 1\n            if self.current_chunk >= self.chunk_size:\n                await self.commit()\n\n        async def commit(self):\n            \"\"\"\n            Manually commit and flush the batch indexing query\n            \"\"\"\n            await self._pipeline.execute()\n            self.current_chunk = 0\n\n    def pipeline(self, transaction=True, shard_hint=None):\n        \"\"\"Creates a pipeline for the SEARCH module, that can be used for executing\n        SEARCH commands, as well as classic core commands.\n        \"\"\"\n        p = AsyncPipeline(\n            connection_pool=self.client.connection_pool,\n            response_callbacks=self.MODULE_CALLBACKS,\n            transaction=transaction,\n            shard_hint=shard_hint,\n        )\n        p.index_name = self.index_name\n        return p\n\n\nclass Pipeline(SearchCommands, redis.client.Pipeline):\n    \"\"\"Pipeline for the module.\"\"\"\n\n\nclass AsyncPipeline(AsyncSearchCommands, AsyncioPipeline):\n    \"\"\"AsyncPipeline for the module.\"\"\"\n", "path": "redis/commands/search/__init__.py"}], "after_files": [{"content": "import redis\n\nfrom ...asyncio.client import Pipeline as AsyncioPipeline\nfrom .commands import AsyncSearchCommands, SearchCommands\n\n\nclass Search(SearchCommands):\n    \"\"\"\n    Create a client for talking to search.\n    It abstracts the API of the module and lets you just use the engine.\n    \"\"\"\n\n    class BatchIndexer:\n        \"\"\"\n        A batch indexer allows you to automatically batch\n        document indexing in pipelines, flushing it every N documents.\n        \"\"\"\n\n        def __init__(self, client, chunk_size=1000):\n\n            self.client = client\n            self.execute_command = client.execute_command\n            self._pipeline = client.pipeline(transaction=False, shard_hint=None)\n            self.total = 0\n            self.chunk_size = chunk_size\n            self.current_chunk = 0\n\n        def __del__(self):\n            if self.current_chunk:\n                self.commit()\n\n        def add_document(\n            self,\n            doc_id,\n            nosave=False,\n            score=1.0,\n            payload=None,\n            replace=False,\n            partial=False,\n            no_create=False,\n            **fields,\n        ):\n            \"\"\"\n            Add a document to the batch query\n            \"\"\"\n            self.client._add_document(\n                doc_id,\n                conn=self._pipeline,\n                nosave=nosave,\n                score=score,\n                payload=payload,\n                replace=replace,\n                partial=partial,\n                no_create=no_create,\n                **fields,\n            )\n            self.current_chunk += 1\n            self.total += 1\n            if self.current_chunk >= self.chunk_size:\n                self.commit()\n\n        def add_document_hash(self, doc_id, score=1.0, replace=False):\n            \"\"\"\n            Add a hash to the batch query\n            \"\"\"\n            self.client._add_document_hash(\n                doc_id, conn=self._pipeline, score=score, replace=replace\n            )\n            self.current_chunk += 1\n            self.total += 1\n            if self.current_chunk >= self.chunk_size:\n                self.commit()\n\n        def commit(self):\n            \"\"\"\n            Manually commit and flush the batch indexing query\n            \"\"\"\n            self._pipeline.execute()\n            self.current_chunk = 0\n\n    def __init__(self, client, index_name=\"idx\"):\n        \"\"\"\n        Create a new Client for the given index_name.\n        The default name is `idx`\n\n        If conn is not None, we employ an already existing redis connection\n        \"\"\"\n        self.MODULE_CALLBACKS = {}\n        self.client = client\n        self.index_name = index_name\n        self.execute_command = client.execute_command\n        self._pipeline = client.pipeline\n\n    def pipeline(self, transaction=True, shard_hint=None):\n        \"\"\"Creates a pipeline for the SEARCH module, that can be used for executing\n        SEARCH commands, as well as classic core commands.\n        \"\"\"\n        p = Pipeline(\n            connection_pool=self.client.connection_pool,\n            response_callbacks=self.MODULE_CALLBACKS,\n            transaction=transaction,\n            shard_hint=shard_hint,\n        )\n        p.index_name = self.index_name\n        return p\n\n\nclass AsyncSearch(Search, AsyncSearchCommands):\n    class BatchIndexer(Search.BatchIndexer):\n        \"\"\"\n        A batch indexer allows you to automatically batch\n        document indexing in pipelines, flushing it every N documents.\n        \"\"\"\n\n        async def add_document(\n            self,\n            doc_id,\n            nosave=False,\n            score=1.0,\n            payload=None,\n            replace=False,\n            partial=False,\n            no_create=False,\n            **fields,\n        ):\n            \"\"\"\n            Add a document to the batch query\n            \"\"\"\n            self.client._add_document(\n                doc_id,\n                conn=self._pipeline,\n                nosave=nosave,\n                score=score,\n                payload=payload,\n                replace=replace,\n                partial=partial,\n                no_create=no_create,\n                **fields,\n            )\n            self.current_chunk += 1\n            self.total += 1\n            if self.current_chunk >= self.chunk_size:\n                await self.commit()\n\n        async def commit(self):\n            \"\"\"\n            Manually commit and flush the batch indexing query\n            \"\"\"\n            await self._pipeline.execute()\n            self.current_chunk = 0\n\n    def pipeline(self, transaction=True, shard_hint=None):\n        \"\"\"Creates a pipeline for the SEARCH module, that can be used for executing\n        SEARCH commands, as well as classic core commands.\n        \"\"\"\n        p = AsyncPipeline(\n            connection_pool=self.client.connection_pool,\n            response_callbacks=self.MODULE_CALLBACKS,\n            transaction=transaction,\n            shard_hint=shard_hint,\n        )\n        p.index_name = self.index_name\n        return p\n\n\nclass Pipeline(SearchCommands, redis.client.Pipeline):\n    \"\"\"Pipeline for the module.\"\"\"\n\n\nclass AsyncPipeline(AsyncSearchCommands, AsyncioPipeline, Pipeline):\n    \"\"\"AsyncPipeline for the module.\"\"\"\n", "path": "redis/commands/search/__init__.py"}]}