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

Method test_no_index

tests/test_search.py:617–703  ·  view source on GitHub ↗
(self, client)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

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

Tested by

no test coverage detected