Update aliases and delete indices atomically

  • POST /_aliases
Auth

Applies one or more actions in a single request:

  • Add a data stream or index to an alias.
  • Remove a data stream or index from an alias.
  • Delete an index in that same request, so the deletion and the alias changes are applied together.

For example, you can replace an index with an alias of the same name.

Note

Every remove_index action in the request runs first, before any add or remove actions, no matter where it sits in the actions array.

Required authorization

Index privileges manage

Query parameters

master_timeout string · default: 30s

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.

timeout string · default: 30s

Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

Request body

actions object[]

Actions to perform.

add object

Adds a data stream or index to an alias. If the alias doesn’t exist, the add action creates it.

alias string

Alias for the action. Index alias names support date math.

aliases union string | string[]

Aliases for the action. Index alias names support date math.

filter {} Query

Query used to limit documents the alias can access.

index string

Data stream or index for the action. Supports wildcards (*). Wildcard patterns that match both data streams and indices return an error.

indices union oneOf

Data streams or indices for the action. Supports wildcards (*). Wildcard patterns that match both data streams and indices return an error.

One of: string[] or string
index_routing 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.

is_hidden boolean · default: false

If true, the alias is hidden.

is_write_index boolean

If true, sets the write index or data stream for the alias.

routing string

Value used to route indexing and search operations to a specific shard. Data stream aliases don’t support this parameter.

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

must_exist boolean · default: false

If true, the alias must exist to perform the action.

remove object

Removes a data stream or index from an alias.

alias string

Alias for the action. Index alias names support date math.

aliases union string | string[]

Aliases for the action. Index alias names support date math.

index string

Data stream or index for the action. Supports wildcards (*).

indices union oneOf

Data streams or indices for the action. Supports wildcards (*).

One of: string[] or string
must_exist boolean · default: false

If true, the alias must exist to perform the action.

remove_index object

Deletes an index. You cannot use this action on aliases or data streams.

index string

Data stream or index for the action. Supports wildcards (*).

indices union oneOf

Data streams or indices for the action. Supports wildcards (*).

One of: string[] or string
must_exist boolean · default: false

If true, the alias must exist to perform the action.

Response

application/json
acknowledged boolean required

For a successful response, this value is always true. On failure, an exception is returned instead.

errors boolean

If true, at least one alias action failed. The request still returns HTTP 200.

action_results object[]

Results for each action in the request. Returned only when errors is true.

action object required

The action this result describes.

type enum required

The action that was applied.

Values: add remove remove_index
indices string[] required

Resolved data streams or indices for the action.

aliases string[] required

Aliases for the action.

status number required

HTTP status for this action. 200 when the action succeeds.

error object

Cause of the failure. Returned only when this action fails.

type string required

The type of error

reason union string nullable

A human-readable explanation of the error, in English.

One of: string
stack_trace string

The server stack trace. Present only if the error_trace=true parameter was sent with the request.

caused_by object
Same fields as error in action_results
root_cause object[]
Same fields as error in action_results
suppressed object[]
Same fields as error in action_results