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

Method test_example

tests/test_asyncio/test_search.py:551–570  ·  view source on GitHub ↗
(self, decoded_r: redis.Redis)

Source from the content-addressed store, hash-verified

549
550 @pytest.mark.redismod
551 async def test_example(self, decoded_r: redis.Redis):
552 # Creating the index definition and schema
553 await decoded_r.ft().create_index(
554 (TextField("title", weight=5.0), TextField("body"))
555 )
556
557 # Indexing a document
558 await decoded_r.hset(
559 "doc1",
560 mapping={
561 "title": "RediSearch",
562 "body": "Redisearch impements a search engine on top of redis",
563 },
564 )
565
566 # Searching with complex parameters:
567 q = Query("search engine").verbatim().no_content().paging(0, 5)
568
569 res = await decoded_r.ft().search(q)
570 assert res is not None
571
572 @pytest.mark.redismod
573 async def test_auto_complete(self, decoded_r: redis.Redis):

Callers

nothing calls this directly

Calls 9

TextFieldClass · 0.90
QueryClass · 0.90
create_indexMethod · 0.80
hsetMethod · 0.80
pagingMethod · 0.80
no_contentMethod · 0.80
ftMethod · 0.45
verbatimMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected