Get a list of suggestions from the AutoCompleter, for a given prefix. Parameters: prefix : str The prefix we are searching. **Must be valid ascii or utf-8** fuzzy : bool If set to true, the prefix search is done in fuzzy mode. **
(
self,
key: str,
prefix: str,
fuzzy: bool = False,
num: int = 10,
with_scores: bool = False,
with_payloads: bool = False,
)
| 1648 | return self.execute_command(SUGDEL_COMMAND, key, string) |
| 1649 | |
| 1650 | def sugget( |
| 1651 | self, |
| 1652 | key: str, |
| 1653 | prefix: str, |
| 1654 | fuzzy: bool = False, |
| 1655 | num: int = 10, |
| 1656 | with_scores: bool = False, |
| 1657 | with_payloads: bool = False, |
| 1658 | ) -> List[SuggestionParser]: |
| 1659 | """ |
| 1660 | Get a list of suggestions from the AutoCompleter, for a given prefix. |
| 1661 | |
| 1662 | Parameters: |
| 1663 | |
| 1664 | prefix : str |
| 1665 | The prefix we are searching. **Must be valid ascii or utf-8** |
| 1666 | fuzzy : bool |
| 1667 | If set to true, the prefix search is done in fuzzy mode. |
| 1668 | **NOTE**: Running fuzzy searches on short (<3 letters) prefixes |
| 1669 | can be very |
| 1670 | slow, and even scan the entire index. |
| 1671 | with_scores : bool |
| 1672 | If set to true, we also return the (refactored) score of |
| 1673 | each suggestion. |
| 1674 | This is normally not needed, and is NOT the original score |
| 1675 | inserted into the index. |
| 1676 | with_payloads : bool |
| 1677 | Return suggestion payloads |
| 1678 | num : int |
| 1679 | The maximum number of results we return. Note that we might |
| 1680 | return less. The algorithm trims irrelevant suggestions. |
| 1681 | |
| 1682 | Returns: |
| 1683 | |
| 1684 | list: |
| 1685 | A list of Suggestion objects. If with_scores was False, the |
| 1686 | score of all suggestions is 1. |
| 1687 | |
| 1688 | For more information see `FT.SUGGET <https://redis.io/commands/ft.sugget>`_. |
| 1689 | """ # noqa |
| 1690 | args = [SUGGET_COMMAND, key, prefix, "MAX", num] |
| 1691 | if fuzzy: |
| 1692 | args.append(FUZZY) |
| 1693 | if with_scores: |
| 1694 | args.append(WITHSCORES) |
| 1695 | if with_payloads: |
| 1696 | args.append(WITHPAYLOADS) |
| 1697 | |
| 1698 | res = self.execute_command(*args) |
| 1699 | results = [] |
| 1700 | if not res: |
| 1701 | return results |
| 1702 | |
| 1703 | parser = SuggestionParser(with_scores, with_payloads, res) |
| 1704 | return [s for s in parser] |
| 1705 | |
| 1706 | def synupdate(self, groupid: str, skipinitial: bool = False, *terms: List[str]): |
| 1707 | """ |