The add alias request allows us to alias an existing index to another name:
val resp = client.execute {
add alias "places" on "locations"
}
Aliases can include filters to assist with partitioning data (such as limiting results to a certain customer or project) or commonly applied filtering:
val resp = client.execute {
add alias "uk-locations" on "locations" filter termFilter("country", "uk")
}
Existing aliases can be removed using a similar request:
val resp = client.execute {
remove alias "places" on "locations"
}
Multiple operations on aliases can be executed atomically:
val resp = client.execute {
aliases(
remove alias "places" on "old_locations",
add alias "places" on "new_locations"
)
}
For more information on the options for aliases, consult the official ElasticSearch docs.