为单个弹性搜索索引维护两个别名的用途是什么 [英] What is the use of maintaining two aliases for a single Elastic Search Index

查看:73
本文介绍了为单个弹性搜索索引维护两个别名的用途是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在探索Elastic Search.

I have been exploring Elastic Search lately.

我一直在经历别名.我看到ES提供了一个API,可以为单个索引创建多个别名,如下所示:

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" } }] }

引用: https://www.elastic.co/guide/zh-CN/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.

推荐答案

可能的用例是当您的应用程序必须从旧索引到具有零停机时间的新索引.

比方说,由于某些原因,您想为索引重新索引,并且没有在索引中使用别名,那么您需要更新应用程序以使用新的索引名称.

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.

这有什么帮助?

假设您的应用程序使用别名而不是索引名.

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

让我们创建一个索引:

PUT /my_index

创建别名:

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.

注意:您需要在将别名添加到新索引的同时,从旧索引中删除别名.您可以原子地使用_aliases端点来实现.

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.

一本好书:弹性

根据您的问题为单个索引维护两个别名的用法:

  • 在索引中的一部分文档上创建视图".

使用具有相同别名的多个索引:

  • 使用相同名称将多个索引分组,如果要同时对多个索引执行单个查询,这将很有帮助.

  • 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.

这篇关于为单个弹性搜索索引维护两个别名的用途是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆