Aliases API

edit

Performs one or more alias actions in a single atomic operation.

POST _aliases
{
  "actions": [
    {
      "add": {
        "index": "my-data-stream",
        "alias": "my-alias"
      }
    }
  ]
}

Request

edit

POST _aliases

Prerequisites

edit
  • If the Elasticsearch security features are enabled, you must have the following index privileges:

    • To use the add or remove action, you must have the manage index privilege for the alias and its data streams or indices.
    • To use the remove_index action, you must have the manage index privilege for the index.

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, the add and remove actions require this parameter. For the remove action, this parameter supports wildcards (*). The remove_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, the add and remove actions require this parameter. For the remove action, this parameter supports wildcards (*). The remove_index action doesn’t support this parameter.
filter

(Optional, Query DSL object Query used to limit documents the alias can access.

Only the add action supports this parameter.

index
(Required*, string) Data stream or index for the action. Supports wildcards (*). If indices is not specified, this parameter is required. For the add and remove_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 (*). If index is not specified, this parameter is required. For the add and remove_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 to false. All data streams or indices for the alias must have the same is_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 and is_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 to false. Only the remove 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.