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

Elasticsearch - Mapping conflict error upgrading from 1.5 to 2.0

当试图启动我的集群的主节点时,就在从 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]]]

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

日志以此结尾:

[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)

节点关闭..

我仔细阅读了问题#13169 and #13345,但是none对我有帮助,节点一直无法启动。

我知道当 ES 启动时 changing the mappings 很容易,但我有点卡在这里。

有什么想法吗?

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

your logstash-2015.10.18 index has a timestamp field which is mapped as a string on one type and as a date on another type, which is something that elasticsearch can't cope with. In elasticsearch 1.x this issue would be silent and only trip when trying to search/sort/aggregate on a field. In Elasticsearch 2.0, we detect these inconsistencies more proactively.

最终答案在这里:https://www.elastic.co/blog/great-mapping-refactoring

You will not be able to upgrade indices with conflicting field mappings to Elasticsearch v2.0.

If the data in these indices is no longer needed, then you can simply delete the indices, otherwise you will need to reindex your data with correct mappings.

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