MCPcopy
hub / github.com/redis/redis-py / search

Method search

redis/commands/search/commands.py:1755–1788  ·  view source on GitHub ↗

Search the index for a given query, and return a result of documents ### Parameters - **query**: the search query. Either a text for simple queries with default parameters, or a Query object for complex queries. See RediSearch's do

(
        self,
        query: Union[str, Query],
        query_params: Optional[Dict[str, Union[str, int, float, bytes]]] = None,
    )

Source from the content-addressed store, hash-verified

1753 return self._parse_results(INFO_CMD, res)
1754
1755 async def search(
1756 self,
1757 query: Union[str, Query],
1758 query_params: Optional[Dict[str, Union[str, int, float, bytes]]] = None,
1759 ):
1760 """
1761 Search the index for a given query, and return a result of documents
1762
1763 ### Parameters
1764
1765 - **query**: the search query. Either a text for simple queries with
1766 default parameters, or a Query object for complex queries.
1767 See RediSearch's documentation on query format
1768
1769 For more information see `FT.SEARCH <https://redis.io/commands/ft.search>`_.
1770 """ # noqa
1771 args, query = self._mk_query_args(query, query_params=query_params)
1772 st = time.monotonic()
1773
1774 options = {}
1775 if not check_protocol_version(get_protocol_version(self.client), 3):
1776 options[NEVER_DECODE] = True
1777 if isinstance(self, Pipeline):
1778 options["query"] = query
1779 options["duration"] = 0
1780
1781 res = await self.execute_command(SEARCH_CMD, *args, **options)
1782
1783 if isinstance(res, Pipeline):
1784 return res
1785
1786 return self._parse_results(
1787 SEARCH_CMD, res, query=query, duration=(time.monotonic() - st) * 1000.0
1788 )
1789
1790 @experimental_method()
1791 async def hybrid_search(

Callers

nothing calls this directly

Calls 6

check_protocol_versionFunction · 0.90
_mk_query_argsMethod · 0.80
monotonicMethod · 0.80
_parse_resultsMethod · 0.80
get_protocol_versionFunction · 0.50
execute_commandMethod · 0.45

Tested by

no test coverage detected