Elasticsearch - 映射冲突错误从1.5升级到2.0

chi*_*adx 5 mapping elasticsearch

当我尝试启动集群的主节点时,刚刚从1.5升级到2.0(是的,这是一个很大的跳转),我收到此错误日志:

[2015-11-03 18:15:10,948][ERROR][gateway                  ] [mon-01] failed to read local state, exiting...
java.lang.IllegalStateException: unable to upgrade the mappings for the index [logstash-2015.10.18], reason: [Mapper for [timestamp] conflicts with existing mapping in other types:
[mapper [timestamp] cannot be changed from type [date] to [string]]]
Run Code Online (Sandbox Code Playgroud)

不幸的是,我没有该字段的详细描述或该字段的相关分析器配置,但正如其名称所述,它是logstash的时间戳,因此它应该看起来像下列之一:

  • "dd/MMM/yyyy:HH:mm:ss Z"
  • "YYYY-MM-dd HH:mm:ss"
  • "HH:MM:SS"
  • "YYYY-MM-dd HH:mm:ss,SSS ZZ"
  • "YYYY-MM-dd HH:mm:ss,SSSZZ"
  • "YYYY-MM-dd HH:mm:ss,SSS"

日志以此结束:

[2015-11-03 18:15:11,383][ERROR][bootstrap                ] Guice Exception: java.lang.IllegalStateException: unable to upgrade the mappings for the index [logstash-2015.10.18], reason: [Mapper for [timestamp] conflicts with existing mapping in other types:
[mapper [timestamp] cannot be changed from type [date] to [string]]]
Likely root cause: java.lang.IllegalArgumentException: Mapper for [timestamp] conflicts with existing mapping in other types:
[mapper [timestamp] cannot be changed from type [date] to [string]]
    at org.elasticsearch.index.mapper.FieldTypeLookup.checkCompatibility(FieldTypeLookup.java:117)
    at org.elasticsearch.index.mapper.MapperService.checkNewMappersCompatibility(MapperService.java:345)
    at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:296)
    at org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:242)
    at org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService.checkMappingsCompatibility(MetaDataIndexUpgradeService.java:329)
    at org.elasticsearch.cluster.metadata.MetaDataIndexUpgradeService.upgradeIndexMetaData(MetaDataIndexUpgradeService.java:112)
    at org.elasticsearch.gateway.GatewayMetaState.pre20Upgrade(GatewayMetaState.java:226)
    at org.elasticsearch.gateway.GatewayMetaState.<init>(GatewayMetaState.java:85)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at <<<guice>>>
    at org.elasticsearch.node.Node.<init>(Node.java:198)
    at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Run Code Online (Sandbox Code Playgroud)

并且节点关闭..

我仔细阅读了问题#13169#13345,但这些都没有帮助我,节点一直无法启动.

我知道当ES升级时改变映射很容易,但我有点卡在这里.

任何的想法?

chi*_*adx 5

从Elasticsearch开发,它看起来像我的数据中的问题,而不是ES本身:https://github.com/elastic/elasticsearch/issues/14491

你的logstash-2015.10.18索引有一个timestamp字段,它被映射为一种类型的字符串和另一种类型的日期,这是elasticsearch无法应付的.在elasticsearch 1.x中,这个问题是静默的,只有在尝试搜索/排序/聚合字段时才会出现问题.在Elasticsearch 2.0中,我们更主动地检测这些不一致.

最终答案如下:https://www.elastic.co/blog/great-mapping-refactoring

您将无法将具有冲突字段映射的索引升级到Elasticsearch v2.0.

如果不再需要这些索引中的数据,那么您可以简单地删除索引,否则您将需要使用正确的映射重新索引数据.

此工具可能有助于提取数据并重新导入数据:https://github.com/taskrabbit/elasticsearch-dump