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.
External documentation -
Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
External documentation
Body
-
Query used to limit documents the alias can access.
External documentation -
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. -
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. -
Value used to route indexing and search operations to a specific shard. Data stream aliases don’t support this parameter.
-
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.
POST /my-index-2099.05.06-000001/_alias/my-alias { "filter": { "bool": { "filter": [ { "range": { "@timestamp": { "gte": "now-1d/d", "lt": "now/d" } } }, { "term": { "user.id": "kimchy" } } ] } } }
resp = client.indices.put_alias( index="my-index-2099.05.06-000001", name="my-alias", filter={ "bool": { "filter": [ { "range": { "@timestamp": { "gte": "now-1d/d", "lt": "now/d" } } }, { "term": { "user.id": "kimchy" } } ] } }, )
const response = await client.indices.putAlias({ index: "my-index-2099.05.06-000001", name: "my-alias", filter: { bool: { filter: [ { range: { "@timestamp": { gte: "now-1d/d", lt: "now/d", }, }, }, { term: { "user.id": "kimchy", }, }, ], }, }, });
response = client.indices.put_alias( index: "my-index-2099.05.06-000001", name: "my-alias", body: { "filter": { "bool": { "filter": [ { "range": { "@timestamp": { "gte": "now-1d/d", "lt": "now/d" } } }, { "term": { "user.id": "kimchy" } } ] } } } )
$resp = $client->indices()->putAlias([ "index" => "my-index-2099.05.06-000001", "name" => "my-alias", "body" => [ "filter" => [ "bool" => [ "filter" => array( [ "range" => [ "@timestamp" => [ "gte" => "now-1d/d", "lt" => "now/d", ], ], ], [ "term" => [ "user.id" => "kimchy", ], ], ), ], ], ], ]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"filter":{"bool":{"filter":[{"range":{"@timestamp":{"gte":"now-1d/d","lt":"now/d"}}},{"term":{"user.id":"kimchy"}}]}}}' "$ELASTICSEARCH_URL/my-index-2099.05.06-000001/_alias/my-alias"
client.indices().updateAliases(u -> u .actions(a -> a .add(ad -> ad .alias("my-alias") .index("my-data-stream") ) ) );
{ "filter": { "bool": { "filter": [ { "range": { "@timestamp": { "gte": "now-1d/d", "lt": "now/d" } } }, { "term": { "user.id": "kimchy" } } ] } } }
{ "is_write_index": true }
{ "routing": "1" }