What is the use of maintaining two aliases for a single Elastic Search Index

亡梦爱人 提交于 2021-02-10 14:18:10

问题


I have been exploring Elastic Search lately.

I have been going through aliases. I see ES provides an API to create multiple aliases to a single index like below:

{ "actions" : [{ "add" : { "indices" : ["test1", "test2"], "alias" : "alias1" } }] }

Refer: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html#indices-aliases

I'm wondering what is the use case of this.

Won't the queries on aliases get split if an alias point to multiple indices?

I have tried getting the info, but failed to do so as everywhere it's being explained how to acheive this but not the use case.

Directing me to a resource where I could get more info would also help.


回答1:


A possible use case is when your application has to switch from an old index to a newindex with zero downtime.

Let's say you want to reindex an index because of some reasons and you're not using aliases with your index then you need to update your application to use the new index name.

How this is helpful?

Assume that your application is using the alias instead of an index name.

Let's create an index:

PUT /my_index

Create its alias:

PUT /my_index/_alias/my_index_alias

Now you've decided to reindex your index (maybe you want to change the existing mapping).

Once documents have been reindexed correctly, you can switch your alias to point to the new index.

Note: You need to remove the alias from the old index at the same time as we add it to the new index. You can do it using _aliases endpoint atomically.

A good read : elastic

As per your question usage of maintaining two aliases for a single index:

  • Create “views” on a subset of the documents in an index.

Using multiple indices having same alias:

  • Group multiple indices under same name, which is helpful if you want to perform a single query on multiple index at the same time.

  • But you can't insert/index data using this strategy.



来源:https://stackoverflow.com/questions/51669961/what-is-the-use-of-maintaining-two-aliases-for-a-single-elastic-search-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!