Create or update an alias Generally available
All methods and paths for this operation:
Adds a data stream or index to an alias.
Path parameters
-
Comma-separated list of data streams or indices to add. Supports wildcards (
*
). Wildcard patterns that match both data streams and indices return an error. -
Alias to update. If the alias doesn’t exist, the request creates it. Index alias names support date math.
Query parameters
-
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.
Values are
-1
or0
. -
Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
Values are
-1
or0
.
Body
-
An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
External documentation -
If
true
, sets the write index or data stream for the alias. If an alias points to multiple indices or data streams andis_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.
POST _aliases { "actions": [ { "add": { "index": "my-data-stream", "alias": "my-alias" } } ] }
resp = client.indices.update_aliases( actions=[ { "add": { "index": "my-data-stream", "alias": "my-alias" } } ], )
const response = await client.indices.updateAliases({ actions: [ { add: { index: "my-data-stream", alias: "my-alias", }, }, ], });
response = client.indices.update_aliases( body: { "actions": [ { "add": { "index": "my-data-stream", "alias": "my-alias" } } ] } )
$resp = $client->indices()->updateAliases([ "body" => [ "actions" => array( [ "add" => [ "index" => "my-data-stream", "alias" => "my-alias", ], ], ), ], ]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"actions":[{"add":{"index":"my-data-stream","alias":"my-alias"}}]}' "$ELASTICSEARCH_URL/_aliases"
client.indices().updateAliases(u -> u .actions(a -> a .add(ad -> ad .alias("my-alias") .index("my-data-stream") ) ) );
{ "actions": [ { "add": { "index": "my-data-stream", "alias": "my-alias" } } ] }