Back to Redis

FT.ALTER

content/commands/ft.alter.md

latest2.7 KB
Original Source

Add a new attribute to the index. Adding an attribute to the index causes any future document updates to use the new attribute when indexing and reindexing existing documents.

Examples

Required arguments

<details open> <summary><code>index</code></summary>

is index name to create.

</details> <details open> <summary><code>SKIPINITIALSCAN</code></summary>

if set, does not scan and index.

</details> <details open> <summary><code>SCHEMA ADD {attribute} {options} ...</code></summary>

after the SCHEMA keyword, declares which fields to add:

  • attribute is attribute to add.
  • options are attribute options. Refer to [FT.CREATE]({{< relref "commands/ft.create/" >}}) for more information.

<note><b>Note:</b>

Depending on how the index was created, you may be limited by the number of additional text attributes which can be added to an existing index. If the current index contains fewer than 32 text attributes, then SCHEMA ADD will only be able to add attributes up to 32 total attributes (meaning that the index will only ever be able to contain 32 total text attributes). If you wish for the index to contain more than 32 attributes, create it with the MAXTEXTFIELDS option. </note>

</details>

Examples

<details open> <summary><b>Alter an index</b></summary>

{{< highlight bash >}} 127.0.0.1:6379> FT.ALTER idx SCHEMA ADD id2 NUMERIC SORTABLE OK {{< / highlight >}}

</details>

Redis Software and Redis Cloud compatibility

| 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> | |

Return information

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

One of the following:

  • [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}): OK if executed correctly.
  • [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: no such index, invalid schema syntax.

-tab-sep-

One of the following:

  • [Simple string reply]({{< relref "/develop/reference/protocol-spec#simple-strings" >}}): OK if executed correctly.
  • [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: no such index, invalid schema syntax.

{{< /multitabs >}}

See also

[FT.CREATE]({{< relref "commands/ft.create/" >}})

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