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

Method sugadd

redis/commands/search/commands.py:1610–1631  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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&#x27;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 """

Callers 2

test_auto_completeMethod · 0.45
test_auto_completeMethod · 0.45

Calls 5

pipelineMethod · 0.45
getMethod · 0.45
appendMethod · 0.45
execute_commandMethod · 0.45
executeMethod · 0.45

Tested by 2

test_auto_completeMethod · 0.36
test_auto_completeMethod · 0.36