- Elasticsearch 7.0 Cookbook(Fourth Edition)
- Alberto Paro
- 183字
- 2021-06-24 14:52:27
How to do it...
The URL format for control aliases is as follows:
http://<server>/_aliases
http://<server>/<index>/_alias/<alias_name>
For managing the index aliases, we will perform the following steps:
- We are reading the aliases and statuses for all indices using the REST API, so the method will be GET. An example of a call is as follows:
GET /_aliases
- This gives a response similar to this one:
{
".monitoring-es-7-2019.04.06" : {
"aliases" : { }
},
"myindex" : {
"aliases" : { }
}
}
- Aliases can be changed with add and delete commands.
- To read an alias for a single index, we use the _alias endpoint:
GET /myindex/_alias
The result should be as follows:
{
"myindex" : {
"aliases" : { }
}
}
- To add an alias, type the following command:
PUT /myindex/_alias/myalias1
The result should be as follows:
{
"acknowledged" : true
}
This action adds the myindex index to the myalias1 alias.
- To delete an alias, type the following command:
DELETE /myindex/_alias/myalias1
The result should be as follows:
{
"acknowledged" : true
}
The delete action removed myindex from the myalias1 alias.