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

Method test_no_index

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

Source from the content-addressed store, hash-verified

623
624 @pytest.mark.redismod
625 async def test_no_index(self, decoded_r: redis.Redis):
626 await decoded_r.ft().create_index(
627 (
628 TextField("field"),
629 TextField("text", no_index=True, sortable=True),
630 NumericField("numeric", no_index=True, sortable=True),
631 GeoField("geo", no_index=True, sortable=True),
632 TagField("tag", no_index=True, sortable=True),
633 )
634 )
635
636 await decoded_r.hset(
637 "doc1",
638 mapping={
639 "field": "aaa",
640 "text": "1",
641 "numeric": "1",
642 "geo": "1,1",
643 "tag": "1",
644 },
645 )
646 await decoded_r.hset(
647 "doc2",
648 mapping={
649 "field": "aab",
650 "text": "2",
651 "numeric": "2",
652 "geo": "2,2",
653 "tag": "2",
654 },
655 )
656 await self.waitForIndex(decoded_r, "idx")
657
658 if expects_resp2_shape(decoded_r) or expects_unified_shape(decoded_r):
659 res = await decoded_r.ft().search(Query("@text:aa*"))
660 assert 0 == res.total
661
662 res = await decoded_r.ft().search(Query("@field:aa*"))
663 assert 2 == res.total
664
665 res = await decoded_r.ft().search(Query("*").sort_by("text", asc=False))
666 assert 2 == res.total
667 assert "doc2" == res.docs[0].id
668
669 res = await decoded_r.ft().search(Query("*").sort_by("text", asc=True))
670 assert "doc1" == res.docs[0].id
671
672 res = await decoded_r.ft().search(Query("*").sort_by("numeric", asc=True))
673 assert "doc1" == res.docs[0].id
674
675 res = await decoded_r.ft().search(Query("*").sort_by("geo", asc=True))
676 assert "doc1" == res.docs[0].id
677
678 res = await decoded_r.ft().search(Query("*").sort_by("tag", asc=True))
679 assert "doc1" == res.docs[0].id
680 elif expects_resp3_shape(decoded_r):
681 res = await decoded_r.ft().search(Query("@text:aa*"))
682 assert 0 == res["total_results"]

Callers

nothing calls this directly

Calls 14

TextFieldClass · 0.90
NumericFieldClass · 0.90
GeoFieldClass · 0.90
TagFieldClass · 0.90
expects_resp2_shapeFunction · 0.90
expects_unified_shapeFunction · 0.90
QueryClass · 0.90
expects_resp3_shapeFunction · 0.90
create_indexMethod · 0.80
hsetMethod · 0.80
ftMethod · 0.45
waitForIndexMethod · 0.45

Tested by

no test coverage detected