Aliases API
editAliases API
editPerforms one or more alias actions in a single atomic operation.
POST _aliases { "actions": [ { "add": { "index": "my-data-stream", "alias": "my-alias" } } ] }
Request
editPOST _aliases
Prerequisites
edit-
If the Elasticsearch security features are enabled, you must have the following index privileges:
-
To use the
add
orremove
action, you must have themanage
index privilege for the alias and its data streams or indices. -
To use the
remove_index
action, you must have themanage
index privilege for the index.
-
To use the
Query parameters
edit-
master_timeout
-
(Optional, time units)
Period to wait for a connection to the master node. If no response is received
before the timeout expires, the request fails and returns an error. Defaults to
30s
. -
timeout
-
(Optional, time units)
Period to wait for a response. If no response is received before the timeout
expires, the request fails and returns an error. Defaults to
30s
.
Request body
edit-
actions
-
(Required, array of objects) Actions to perform.
Properties of
actions
objects-
<action>
-
(Required, object) The key is the action type. At least one action is required.
Valid
<action>
keys-
add
-
Adds a data stream or index to an alias. If the alias doesn’t exist, the
add
action creates it. -
remove
- Removes a data stream or index from an alias.
-
remove_index
- Deletes an index. You cannot use this action on aliases or data streams.
The object body contains options for the alias. Supports an empty object.
Properties of
<action>
-
alias
-
(Required*, string) Alias for the action. Index alias names support
date math. If
aliases
is not specified, theadd
andremove
actions require this parameter. For theremove
action, this parameter supports wildcards (*
). Theremove_index
action doesn’t support this parameter. -
aliases
-
(Required*, array of strings) Aliases for the action. Index alias names support
date math. If
alias
is not specified, theadd
andremove
actions require this parameter. For theremove
action, this parameter supports wildcards (*
). Theremove_index
action doesn’t support this parameter.
-
filter
-
(Optional, Query DSL object Query used to limit documents the alias can access. Data stream aliases don’t support this parameter.
Only the
add
action supports this parameter. -
index
-
(Required*, string) Data stream or index for the action. Supports wildcards
(
*
). Ifindices
is not specified, this parameter is required. For theadd
andremove_index
actions, wildcard patterns that match both data streams and indices return an error. -
indices
-
(Required*, array of strings) Data streams or indices for the action. Supports
wildcards (
*
). Ifindex
is not specified, this parameter is required. For theadd
andremove_index
actions, wildcard patterns that match both data streams and indices return an error.
-
index_routing
-
(Optional, string) Value used to route indexing operations to a specific shard. If specified, this overwrites the
routing
value for indexing operations. Data stream aliases don’t support this parameter.Only the
add
action supports this parameter.
-
is_hidden
-
(Optional, Boolean) If
true
, the alias is hidden. Defaults tofalse
. All data streams or indices for the alias must have the sameis_hidden
value.Only the
add
action supports this parameter.
-
is_write_index
-
(Optional, Boolean) If
true
, sets the write index or data stream for the alias.If an alias points to multiple indices or data streams and
is_write_index
isn’t set, the alias rejects write requests. If an index alias points to one index andis_write_index
isn’t set, the index automatically acts as the write index. Data stream aliases don’t automatically set a write data stream, even if the alias points to one data stream.Only the
add
action supports this parameter. -
must_exist
-
(Optional, Boolean)
If
true
, the alias must exist to perform the action. Defaults tofalse
. Only theremove
action supports this parameter.
-
routing
-
(Optional, string) Value used to route indexing and search operations to a specific shard. Data stream aliases don’t support this parameter.
Only the
add
action supports this parameter.
-
search_routing
-
(Optional, string) Value used to route search operations to a specific shard. If specified, this overwrites the
routing
value for search operations. Data stream aliases don’t support this parameter.Only the
add
action supports this parameter.
-
-