Index Alias API allows the use of a name as an index of aliases, all API automatically converts the alias name of the actual index. Aliases can be mapped to a plurality of indexes, index alias can not have the same name. Aliases can be used to make a unified query multiple indexes and index migration can also be used to achieve functional view
View all aliases
GET / _aliases
Look under an alias index
GET / _alias / alias_name
View aliases beginning with 2017 the index at
GET / _alias / 2017
View an index aliases
GET / index_name / _alias
Add and delete aliases
POST /_aliases
{
"actions" : [
{ "remove" : { "index" : "test1", "alias" : "alias1" } },
{ "add" : { "index" : "test2", "alias" : "alias1" } }
]
}
The alias is associated with more than one index added just a few actions:
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "test1", "alias" : "alias1" } },
{ "add" : { "index" : "test2", "alias" : "alias1" } }
]
}
You can also use an array of
POST /_aliases
{
"actions" : [
{ "add" : { "indices" : ["test1", "test2"], "alias" : "alias1" } }
]
}
You can also use wildcards *
POST /_aliases
{
"actions" : [
{ "add" : { "index" : "test*", "alias" : "all_test_indices" } }
]
}
You can also use the alias achieve similar view function
PUT /test1
{
"mappings": {
"type1": {
"properties": {
"user" : {
"type": "keyword"
}
}
}
}
}
Creating a user views equal kimchy
POST /_aliases
{
"actions" : [
{
"add" : {
"index" : "test1",
"alias" : "alias2",
"filter" : { "term" : { "user" : "kimchy" } }
}
}
]
}
Add a single alias
PUT /{index}/_alias/{name}
examples:
PUT /logs_201305/_alias/2013
PUT /users/_alias/user_12
{
"routing" : "12",
"filter" : {
"term" : {
"user_id" : 12
}
}
}
You can also specify an alias when creating an index
PUT /logs_20162801
{
"mappings" : {
"type" : {
"properties" : {
"year" : {"type" : "integer"}
}
}
},
"aliases" : {
"current_day" : {},
"2016" : {
"filter" : {
"term" : {"year" : 2016 }
}
}
}
}
To delete an alias
DELETE / {index} / _ Alias / {name}
index * | _all | glob pattern | NAME1, NAME2, ...
name * | _all | glob pattern | NAME1, NAME2, ...
DELETE /logs_20162801/_alias/current_day