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

Method search

redis/commands/search/commands.py:1251–1284  ·  redis/commands/search/commands.py::SearchCommands.search

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: Union[Dict[str, Union[str, int, float, bytes]], None] = None,
    )

Source from the content-addressed store, hash-verified

1249 return args, query
1250
1251 def search(
1252 self,
1253 query: Union[str, Query],
1254 query_params: Union[Dict[str, Union[str, int, float, bytes]], None] = None,
1255 ):
1256 class="st">"""
1257 Search the index for a given query, and return a result of documents
1258
1259 class="cm">### Parameters
1260
1261 - **query**: the search query. Either a text for simple queries with
1262 default parameters, or a Query object for complex queries.
1263 See RediSearch&class="cm">#x27;s documentation on query format
1264
1265 For more information see `FT.SEARCH <https://redis.io/commands/ft.search>`_.
1266 class="st">""" class="cm"># noqa
1267 args, query = self._mk_query_args(query, query_params=query_params)
1268 st = time.monotonic()
1269
1270 options = {}
1271 if not check_protocol_version(get_protocol_version(self.client), 3):
1272 options[NEVER_DECODE] = True
1273 if isinstance(self, Pipeline):
1274 options[class="st">"query"] = query
1275 options[class="st">"duration"] = 0
1276
1277 res = self.execute_command(SEARCH_CMD, *args, **options)
1278
1279 if isinstance(res, Pipeline):
1280 return res
1281
1282 return self._parse_results(
1283 SEARCH_CMD, res, query=query, duration=(time.monotonic() - st) * 1000.0
1284 )
1285
1286 @experimental_method()
1287 def hybrid_search(

Callers 15

search_vss.pyFile · 0.45
create_query_tableFunction · 0.45
query_geo.pyFile · 0.45
home_json.pyFile · 0.45
query_em.pyFile · 0.45
query_ft.pyFile · 0.45
geo_index.pyFile · 0.45
query_range.pyFile · 0.45
query_combined.pyFile · 0.45

Calls 6

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

Tested by 15

test_clientMethod · 0.36
test_scoresMethod · 0.36
test_stopwordsMethod · 0.36
test_filtersMethod · 0.36
test_sort_byMethod · 0.36
test_exampleMethod · 0.36
test_no_indexMethod · 0.36
test_summarizeMethod · 0.36
test_aliasMethod · 0.36