opensearch-docs-cn/_opensearch/rest-api/create-alias.md

81 lines
2.7 KiB
Markdown
Raw Normal View History

---
layout: default
2021-06-28 13:36:41 -04:00
title: Alias
parent: REST API reference
grand_parent: OpenSearch
nav_order: 8
---
2021-06-28 13:36:41 -04:00
# Alias
2021-06-28 19:08:28 -04:00
An alias is a virtual pointer that you can use to reference one or more indices. Creating and updating aliases are atomic operations, so you can reindex your data and point an alias at it without any downtime.
## Example
```json
POST _aliases
{
"actions": [
{
"add": {
"index": "movies",
"alias": "movies-alias1"
}
2021-06-28 13:36:41 -04:00
},
{
"remove": {
"index": "old-index",
"alias": "old-index-alias"
}
}
2021-06-28 13:36:41 -04:00
]
}
```
2021-07-01 16:42:13 -04:00
## Path and HTTP methods
2021-06-28 13:36:41 -04:00
```
POST _aliases
```
## URL parameters
2021-06-28 13:36:41 -04:00
All alias parameters are optional.
Parameter | Data Type | Description
:--- | :--- | :---
master_timeout | Time | The amount of time to wait for a response from the master node. Default is `30s`.
timeout | Time | The amount of time to wait for a response from the cluster. Default is `30s`.
## Request body
In your request body, you need to specify what action to take, the alias name, and the index you want to associate with the alias. Other fields are optional.
Field | Data Type | Description | Required
:--- | :--- | :--- | :---
actions | Array | Set of actions you want to perform on the index. Valid options are: `add`, `remove`, and `remove_index`. You must have at least one action in the array. | Yes
add | N/A | Adds an alias to the specified index. | No
remove | N/A | Removes an alias from the specified index. | No
remove_index | N/A | Deletes an index. | No
index | String | Name of the index you want to associate with the alias. Supports wildcard expressions. | Yes if you don't supply an `indices` field in the body.
indices | Array | Array of index names you want to associate with the alias. | Yes if you don't supply an `index` field in the body.
alias | String | The name of the alias. | Yes if you don't supply an `aliases` field in the body.
aliases | Array | Array of alias names. | Yes if you don't supply an `alias` field in the body.
filter | Object | A filter to use with the alias, so the alias points to a filtered part of the index. | No
is_hidden | Boolean | Specifies whether the alias should be hidden from results that include wildcard expressions | No
must_exist | Boolean | Specifies whether the alias to remove must exist. | No
is_write_index | Boolean | Specifies whether the index should be a write index. An alias can only have one write index at a time. | No
routing | String | Used to assign a custom value to a shard for specific operations. | No
index_routing | String | Assigns a custom value to a shard only for index operations. | No
search_routing | String | Assigns a custom value to a shard only for search operations. | No
## Response
```json
{
"acknowledged": true
}
```