Add suggestion terms to the AutoCompleter engine. Each suggestion has a score and string. If kwargs["increment"] is true and the terms are already in the server's dictionary, we increment their scores. For more information see `FT.SUGADD <https://redis.io/co
(self, key, *suggestions, **kwargs)
| 1608 | return self.execute_command(ALIAS_DEL_CMD, alias) |
| 1609 | |
| 1610 | def sugadd(self, key, *suggestions, **kwargs): |
| 1611 | """ |
| 1612 | Add suggestion terms to the AutoCompleter engine. Each suggestion has |
| 1613 | a score and string. |
| 1614 | If kwargs["increment"] is true and the terms are already in the |
| 1615 | server's dictionary, we increment their scores. |
| 1616 | |
| 1617 | For more information see `FT.SUGADD <https://redis.io/commands/ft.sugadd/>`_. |
| 1618 | """ # noqa |
| 1619 | # If Transaction is not False it will MULTI/EXEC which will error |
| 1620 | pipe = self.pipeline(transaction=False) |
| 1621 | for sug in suggestions: |
| 1622 | args = [SUGADD_COMMAND, key, sug.string, sug.score] |
| 1623 | if kwargs.get("increment"): |
| 1624 | args.append("INCR") |
| 1625 | if sug.payload: |
| 1626 | args.append("PAYLOAD") |
| 1627 | args.append(sug.payload) |
| 1628 | |
| 1629 | pipe.execute_command(*args) |
| 1630 | |
| 1631 | return pipe.execute()[-1] |
| 1632 | |
| 1633 | def suglen(self, key: str) -> int: |
| 1634 | """ |