elastic / elasticsearch-migration

This plugin will help you to check whether you can upgrade directly to the next major version of Elasticsearch, or whether you need to make changes to your data and cluster before doing so.
290 stars 32 forks source link

Cannot generate dynamic mappings of type [_id] for [_id]] #91

Closed SjonHortensius closed 8 years ago

SjonHortensius commented 8 years ago

I keep gettting this error while attempting to reindex a few indexes. Since the index contains data from graylog, the generated _mappings are quite long; but nothing obviously wrong. Full message:

[2016-11-01 16:57:20,897][DEBUG][action.bulk              ] [NODE] [graylog2_0-2.4.0][0] failed to execute bulk item (index) index {[graylog2_0-2.4.0][message][1ea85f90-xxx00cbcdbb], source[{"gl2_source_node":"713372bd-x","line":0,"Boot_id":"942dxa08711e856d4ca3d","version":"1.0","timestamp":"2014-03-11 18:01:07.000","message":"Starting Session 100 of user git.","level":6,"facility":"systemd","_id":"1ea85f90-xxx00cbcdbb","streams":[],"Pid":"1","Uid":"0"}]}
MapperParsingException[Cannot generate dynamic mappings of type [_id] for [_id]]
        at org.elasticsearch.index.mapper.DocumentParser.createBuilderFromFieldType(DocumentParser.java:506)
        at org.elasticsearch.index.mapper.DocumentParser.parseDynamicValue(DocumentParser.java:616)
        at org.elasticsearch.index.mapper.DocumentParser.parseValue(DocumentParser.java:444)
        at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:264)
        at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:124)
        at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:309)
        at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:580)
        at org.elasticsearch.index.shard.IndexShard.prepareIndexOnPrimary(IndexShard.java:559)
        at org.elasticsearch.action.index.TransportIndexAction.prepareIndexOperationOnPrimary(TransportIndexAction.java:211)
        at org.elasticsearch.action.index.TransportIndexAction.executeIndexRequestOnPrimary(TransportIndexAction.java:223)
        at org.elasticsearch.action.bulk.TransportShardBulkAction.shardIndexOperation(TransportShardBulkAction.java:327)
        at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:120)
        at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:68)
        at org.elasticsearch.action.support.replication.TransportReplicationAction$PrimaryPhase.doRun(TransportReplicationAction.java:648)

Document from the error-message

{
   "gl2_source_node":"713372bd-x",
   "line":0,
   "Boot_id":"942dxa08711e856d4ca3d",
   "version":"1.0",
   "timestamp":"2014-03-11 18:01:07.000",
   "message":"Starting Session 100 of user x.",
   "level":6,
   "facility":"systemd",
   "_id":"1ea85f90-xxx00cbcdbb",
   "streams":[],
   "Pid":"1",
   "Uid":"0"
}

Is there anything wrong with these documents? It seems to me META fields should not be mapped? What does this error-message indicate?

clintongormley commented 8 years ago

Hi @SjonHortensius

Yes, you can't have an _id field inside the document _source any more, as of 2.0. You'll need to reindex these documents manually including a script to delete the _id field during reindexing.

SjonHortensius commented 8 years ago

Thanks, I missed that. After setting script.engine.groovy.inline.update: true I added this to my reindex parameters:

  "script": {
    "inline": "ctx._id = ctx._source.remove(\"_id\")"
  }

and that does indeed seem to fix it