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

标签 elasticsearch indexing logstash kibana

重新编制 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/

相关文章:

elasticsearch - 一个索引中的Elasticsearch字段出现在另一索引中

xml - Filebeat进程多XML

c# - Elasticsearch.NET和NEST-搜索总是返回0个结果

spring - 在 java 中使用 elasticSearch 2.3.3 按索引名称和类型删除索引

algorithm - 对网页的全部内容进行哈希处理是如何工作的?

postgresql - PostGIS 中的 K 最近邻查询

java - 从集群收集指标

templates - 如何在多重搜索(_msearch)API中使用Elasticsearch搜索模板?

postgresql - Postgres 中的索引?

regex - 如何在 Logstash 翻译过滤器的 Yaml 文件中使用正则表达式?