FT.ALIASUPDATE
Since 1.1.0Search
Syntax
FT.ALIASUPDATE alias indexPoints alias at index. If the alias does not exist it is created, as FT.ALIASADD would; if it points at another index, it is moved, in one step. This is how an index is replaced without changing the clients: build the new index under a new name (FT.CREATE indexes the keys already there before it replies), then move the alias that clients search to it, and drop the old index.
indexmay be an alias too: the new alias points at the index it names.aliasmay not be the name of an index: that would replace the index, and is refused.
Reply
OK.
Errors
ERR Alias already exists as an index name:aliasnames an index.SEARCH_INDEX_NOT_FOUND Index not found: <index>:indexdoes not exist.
Examples
p2 adds a TAG field that p1 does not have:
> HSET product:3 name chair category furniture
(integer) 2
> HSET product:4 name desk category furniture
(integer) 2
> FT.CREATE p1 ON HASH PREFIX 1 product: SCHEMA name TEXT
OK
> FT.CREATE p2 ON HASH PREFIX 1 product: SCHEMA name TEXT category TAG
OK
> FT.ALIASADD store p1
OK
> FT.SEARCH store "@category:{furniture}" NOCONTENT
(error) Unknown field at offset 0 near category
> FT.ALIASUPDATE store p2
OK
> FT.SEARCH store "@category:{furniture}" NOCONTENT
1) (integer) 2
2) "product:3"
3) "product:4"
> FT.ALIASLIST p1
(empty array)
> FT.ALIASUPDATE p1 store
(error) ERR Alias already exists as an index name