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

Method sugadd

redis/commands/search/commands.py:1965–1986  ·  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

1963 return Document(id=id, **fields)
1964
1965 async def sugadd(self, key, *suggestions, **kwargs):
1966 """
1967 Add suggestion terms to the AutoCompleter engine. Each suggestion has
1968 a score and string.
1969 If kwargs["increment"] is true and the terms are already in the
1970 server&#x27;s dictionary, we increment their scores.
1971
1972 For more information see `FT.SUGADD <https://redis.io/commands/ft.sugadd>`_.
1973 """ # noqa
1974 # If Transaction is not False it will MULTI/EXEC which will error
1975 pipe = self.pipeline(transaction=False)
1976 for sug in suggestions:
1977 args = [SUGADD_COMMAND, key, sug.string, sug.score]
1978 if kwargs.get("increment"):
1979 args.append("INCR")
1980 if sug.payload:
1981 args.append("PAYLOAD")
1982 args.append(sug.payload)
1983
1984 pipe.execute_command(*args)
1985
1986 return (await pipe.execute())[-1]
1987
1988 async def sugget(
1989 self,

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected