(self, client)
| 715 | |
| 716 | @pytest.mark.redismod |
| 717 | def test_summarize(self, client): |
| 718 | self.createIndex(client.ft()) |
| 719 | self.waitForIndex(client, getattr(client.ft(), "index_name", "idx")) |
| 720 | |
| 721 | q = Query('"king henry"').paging(0, 1) |
| 722 | q.highlight(fields=("play", "txt"), tags=("<b>", "</b>")) |
| 723 | q.summarize("txt") |
| 724 | |
| 725 | if expects_resp2_shape(client) or expects_unified_shape(client): |
| 726 | doc = sorted(client.ft().search(q).docs)[0] |
| 727 | assert "<b>Henry</b> IV" == doc.play |
| 728 | assert ( |
| 729 | "ACT I SCENE I. London. The palace. Enter <b>KING</b> <b>HENRY</b>, LORD JOHN OF LANCASTER, the EARL of WESTMORELAND, SIR... " # noqa |
| 730 | == doc.txt |
| 731 | ) |
| 732 | |
| 733 | q = Query('"king henry"').paging(0, 1).summarize().highlight() |
| 734 | |
| 735 | doc = sorted(client.ft().search(q).docs)[0] |
| 736 | assert "<b>Henry</b> ... " == doc.play |
| 737 | assert ( |
| 738 | "ACT I SCENE I. London. The palace. Enter <b>KING</b> <b>HENRY</b>, LORD JOHN OF LANCASTER, the EARL of WESTMORELAND, SIR... " # noqa |
| 739 | == doc.txt |
| 740 | ) |
| 741 | elif expects_resp3_shape(client): |
| 742 | doc = sorted(client.ft().search(q)["results"])[0] |
| 743 | assert "<b>Henry</b> IV" == doc["extra_attributes"]["play"] |
| 744 | assert ( |
| 745 | "ACT I SCENE I. London. The palace. Enter <b>KING</b> <b>HENRY</b>, LORD JOHN OF LANCASTER, the EARL of WESTMORELAND, SIR... " # noqa |
| 746 | == doc["extra_attributes"]["txt"] |
| 747 | ) |
| 748 | |
| 749 | q = Query('"king henry"').paging(0, 1).summarize().highlight() |
| 750 | |
| 751 | doc = sorted(client.ft().search(q)["results"])[0] |
| 752 | assert "<b>Henry</b> ... " == doc["extra_attributes"]["play"] |
| 753 | assert ( |
| 754 | "ACT I SCENE I. London. The palace. Enter <b>KING</b> <b>HENRY</b>, LORD JOHN OF LANCASTER, the EARL of WESTMORELAND, SIR... " # noqa |
| 755 | == doc["extra_attributes"]["txt"] |
| 756 | ) |
| 757 | |
| 758 | @pytest.mark.redismod |
| 759 | @skip_ifmodversion_lt("2.0.0", "search") |
nothing calls this directly
no test coverage detected