Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch - Mapping conflict error upgrading from 1.5 to 2.0

When trying to start the master node of my cluster, just after the upgrade from 1.5 to 2.0 (yeah, that's a big jump), I get this error log:

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

Unfortunately, I don't have the detailed description of the field or the relevant analyzer configuration for the field, but as its name states, it's a timestamp from logstash, so it should look like one of these:

  • "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"

The log ends with this:

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

And the node shuts down..

I have carefully read issues #13169 and #13345, but none of these helped me, the node keeps failing to start.

i know that changing the mappings is easy when ES is up, but I'm kind of stuck here.

Any idea?

like image 924
chilladx Avatar asked Nov 04 '15 07:11

chilladx


People also ask

How do I change the mapping type in Elasticsearch?

It is not possible to update the mapping of an existing field. If the mapping is set to the wrong type, re-creating the index with updated mapping and re-indexing is the only option available. In version 7.0, Elasticsearch has deprecated the document type and the default document type is set to _doc.

What is _type in Elasticsearch?

Basically, a type in Elasticsearch represented a class of similar documents and had a name such as customer or item . Lucene has no concept of document data types, so Elasticsearch would store the type name of each document in a metadata field of a document called _type.


1 Answers

from an Elasticsearch dev, it looks like a problem in my data, and not in ES itself: 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.

The definitive answer is here: 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.

This tool may help to extract data and reimport it: https://github.com/taskrabbit/elasticsearch-dump

like image 193
chilladx Avatar answered Sep 23 '22 03:09

chilladx