Elasticsearch — Using Index Alias
When I wrote the first article about aliases, I strongly recommended using aliases for the indices. But I want to share these details again by adding some other good information in this article. So, let’s start with a few basics and then continue with other topics. What is an index alias for Elasticsearch, and why do we use it?
In short, an alias is a naming strategy to point to multiple indices with one name or the same index with multiple names. After the data streams feature, we can use aliases for the data streams too. An alias can point to one or more indices or data streams. You had to point to an index or data stream while creating an alias. Here is an example of creating an alias for the index and data stream :
POST _aliases
{
"actions": [
{
"add": {
"index": "index_name_or_data_stream_name",
"alias": "the_alias_name"
}
}
]
}
As you know, we create many indices and do massive operations on them. Even our indices have a considerable amount of documents. Every operation can take time. I am sure nobody is doing any process on “production” servers. ^_^ And I am sure that the following information will help you in any case, too. Anyhow, Let’s see our index list, which is prepared for this article:
# GET _cat/indices/book*?v&h=health,index,pri,rep&s=index