Back to Redis

FT.SUGADD

content/commands/ft.sugadd.md

latest2.4 KB
Original Source

Add a suggestion string to an auto-complete suggestion dictionary

Examples

Required arguments

<details open> <summary><code>key</code></summary>

is suggestion dictionary key.

</details> <details open> <summary><code>string</code></summary>

is suggestion string to index.

</details> <details open> <summary><code>score</code></summary>

is floating point number of the suggestion string's weight.

</details>

The auto-complete suggestion dictionary is disconnected from the index definitions and leaves creating and updating suggestions dictionaries to the user.

Optional arguments

<details open> <summary><code>INCR</code></summary>

increments the existing entry of the suggestion by the given score, instead of replacing the score. This is useful for updating the dictionary based on user queries in real time.

</details> <details open> <summary><code>PAYLOAD {payload}</code></summary>

saves an extra payload with the suggestion, that can be fetched by adding the WITHPAYLOADS argument to [FT.SUGGET]({{< relref "commands/ft.sugget/" >}}).

</details>

Examples

<details open> <summary><b>Add a suggestion string to an auto-complete suggestion dictionary</b></summary>

{{< highlight bash >}} 127.0.0.1:6379> FT.SUGADD sug "hello world" 1 (integer) 3 {{< / highlight >}}

</details>

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Not supported"><nobr>❌ Active-Active</nobr></span> | <span title="Not supported">❌ Standard</span> <span title="Not supported"><nobr>❌ Active-Active</nobr></span> | Not supported on clustered databases. |

Return information

{{< multitabs id="ft-sugadd-return-info" tab1="RESP2" tab2="RESP3" >}}

[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): number of elements added to the suggestion dictionary.

-tab-sep-

[Integer reply]({{< relref "/develop/reference/protocol-spec#integers" >}}): number of elements added to the suggestion dictionary.

{{< /multitabs >}}

See also

[FT.SUGGET]({{< relref "commands/ft.sugget/" >}}) | [FT.SUGDEL]({{< relref "commands/ft.sugdel/" >}}) | [FT.SUGLEN]({{< relref "commands/ft.suglen/" >}})

[RediSearch]({{< relref "/develop/ai/search-and-query/" >}})