gpt4 book ai didi

elasticsearch - 在Elasticsearch中为索引重新索引-ELK

转载 作者:行者123 更新时间:2023-12-02 22:58:57 25 4
gpt4 key购买 nike

重新编制 flex 搜索索引的最佳实践是什么? This帖子有几个步骤,涉及在重新索引索引之前停止logstash索引器,但是作为生产服务器,这不是我的选择。

我有一个问题,因为缺少默认的映射模板,索引中没有* .raw字段。我使用了来自Elasticsearch找到的here的映射模板,并配置了我的ES集群以使用它,但是我猜它只能在创建新索引或明确为现有索引重新索引时使用。
/_template?pretty也返回了一个空响应,但是在添加了上述模板后,/_template?pretty显示了一个新模板,但是将要创建的新索引会自动使用该新模板吗?还是我需要配置ES明确要求它使用ES?

我非常感谢您的帮助。

最佳答案

执行此IMO的最佳方法是使用别名来指向您的实际索引。 (https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html),类似于my-index-alias指向my-actual-index-20170101

POST /_aliases
{
"actions" : [
{ "add" : { "index" : "my-actual-index-20170101", "alias" : "my-index-alias" } }
]
}

当查询(或添加内容)到索引时,始终使用别名。

如果需要重新索引,则可以重新索引到另一个索引(例如 my-actual-index-20170127),完成重新索引后,可以更新别名以指向新索引。
POST /_aliases
{
"actions" : [
{ "remove" : { "index" : "my-actual-index-20170101", "alias" : "my-index-alias" } },
{ "add" : { "index" : "my-actual-index-20170127", "alias" : "my-index-alias" } }
]
}

它使您可以重新索引索引,而无需更改任何代码/无需停机。

现在,关于实际的重新索引编制问题-我一直在使用 elasticsearch-reindex节点应用程序,并获得了很多成功( https://www.npmjs.com/package/elasticsearch-reindex)。

它的用法很简单:

用npm( npm install -g elasticsearch-reindex)安装后,您可以运行
elasticsearch-reindex -f http://localhost:9200/my-actual-index-20170101/{type of documents} -t http://localhost:9200/my-actual-index-20170127

关于elasticsearch - 在Elasticsearch中为索引重新索引-ELK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41894819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com