content/commands/ft.spellcheck.md
Perform spelling correction on a query, returning suggestions for misspelled terms
is index with the indexed terms.
</details> <details open> <summary><code>query</code></summary>is search query.
</details>See [Spellchecking]({{< relref "/develop/ai/search-and-query/advanced-concepts/spellcheck" >}}) for more details.
specifies an inclusion (INCLUDE) or exclusion (EXCLUDE) of a custom dictionary. To learn more about managing custom dictionaries, see [FT.DICTADD]({{< relref "commands/ft.dictadd/" >}}), [FT.DICTDEL]({{< relref "commands/ft.dictdel/" >}}), and [FT.DICTDUMP]({{< relref "commands/ft.dictdump/" >}}).
You can specify multiple inclusion and exclusion TERMS.
is maximum Levenshtein distance for spelling suggestions (default: 1, max: 4).
</details> <details open> <summary><code>DIALECT {dialect_version}</code></summary>selects the dialect version under which to execute the query. If not specified, the query will execute under the default dialect version set during module initial loading or via [FT.CONFIG SET]({{< relref "commands/ft.config-set/" >}}) command.
FT.SPELLCHECK returns an array reply, in which each element represents a misspelled term from the query. The misspelled terms are ordered by their order of appearance in the query.
Each misspelled term, in turn, is a 3-element array consisting of the constant string TERM, the term itself and an array of suggestions for spelling corrections.
Each element in the spelling corrections array consists of the score of the suggestion and the suggestion itself. The suggestions array, per misspelled term, is ordered in descending order by score.
The score is calculated by dividing the number of documents in which the suggested term exists by the total number of documents in the index. Results can be normalized by dividing scores by the highest score.
{{< highlight bash >}} 127.0.0.1:6379> FT.SPELLCHECK idx held DISTANCE 2
| Redis Software | Redis Cloud Flexible & Annual | Redis Cloud Free & Fixed | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Supported</nobr></span> | |
{{< multitabs id="ft-spellcheck-return-info" tab1="RESP2" tab2="RESP3" >}}
One of the following:
-tab-sep-
One of the following:
results key containing spell check results for each term.{{< /multitabs >}}
[FT.CONFIG SET]({{< relref "commands/ft.config-set/" >}}) | [FT.DICTADD]({{< relref "commands/ft.dictadd/" >}}) | [FT.DICTDEL]({{< relref "commands/ft.dictdel/" >}}) | [FT.DICTDUMP]({{< relref "commands/ft.dictdump/" >}})