【问题标题】:Transitionning from Elastic 1.4 to 2.x从 Elastic 1.4 过渡到 2.x
【发布时间】:2016-09-07 23:44:39
【问题描述】:

我正在准备将我的弹性搜索服务器从 1.4 更新到 2.X 版本。 我已使用提供的工具 (https://github.com/elastic/elasticsearch-migration/tree/1.x) 准备迁移,但我遇到了映射冲突。

冲突的字段映射: Mapping for field nginx_access:timestamp conflicts with: nginx_error:timestamp. Check parameters: format, norms.enabled, type

实际上,格式不同:

$ curl -XGET /_mapping/nginx_access/field/timestamp?pretty { "timestamp" : { "full_name" : "timestamp", "mapping":{"timestamp":{"type":"string","norms":{"enabled":false},"fields":{"raw":{"type":"string","index":"not_analyzed","ignore_above":256}}}} } }

$ curl -XGET /_mapping/nginx_error/field/timestamp?pretty { "timestamp" : { "full_name" : "timestamp", "mapping":{"timestamp":{"type":"date","format":"yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"}} } }

我知道我无法更改映射类型,因此我需要使用新映射重新创建索引。但是,创建映射的是 Logstash(动态?),我没有任何配置。我可以复制一个索引并在它被索引之前动态更改一个映射类型吗?事实上,我真的不知道如何。在我看来,重新创建索引相当复杂(那里有很多其他文档类型以及很多其他映射)。

我想一劳永逸地更新我的旧索引 - 最好所有时间戳都具有相同的类型。

最简单的解决方案是什么?是否有一个插件可以自动执行此操作? (对于 1.4 版本)

谢谢!

【问题讨论】:

    标签: elasticsearch logstash


    【解决方案1】:

    映射不是由 Logstash 创建的,它们是由 Elasticsearch 在收到文档时动态创建的(取决于字段的内容)。
    您无法更新现有映射,您必须创建新索引,并且在重新索引时,您必须确保时间戳的类型相同,以便它们的映射相同。

    创建索引时可以指定Index pattern,Elasticsearch创建索引时会用到。该模式可以指定您不希望动态生成的映射。你的应该是这样的:

    {
      "nginx": {
        "template": "nginx_*",
        "mappings": {
          "created_at": {
            "type": "date",
            "format": "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
          }
        }
      }
    }
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2015-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-15
      相关资源
      最近更新 更多