Elasticsearch, Kibana : mapper [hits] cannot be changed from type [long] to [integer]
Par Mathieu le mardi 10 octobre 2017, 23:34 - Hacks - Lien permanent
Every time I upgrade my ELK stack, it breaks. This time, it was the Kibana index with this obscurous errors :
[DEBUG][o.e.a.a.i.m.p.TransportPutMappingAction] [logs] failed to put mappings on indices [[[.kibana]]], type [timelion-sheet] java.lang.IllegalArgumentException: mapper [hits] cannot be changed from type [long] to [integer][DEBUG][o.e.a.a.i.m.p.TransportPutMappingAction] [DEBUG][o.e.a.a.i.m.p.TransportPutMappingAction] [logs] failed to put mappings on indices [[[.kibana]]], type [timelion-sheet] java.lang.IllegalArgumentException: mapper [version] cannot be changed from type [long] to [integer]
Here is how to fix it. You will have to re-create an index with the correct mapping, and then reindex it.
First, export your Kibana index mapping and settings :
curl localhost:9200/.kibana/_settings?pretty curl localhost:9200/.kibana/_mapping?pretty
Then, Create and index template with your settings and mapping (don't forget to change the type of the offending fields) :
curl -XPUT "http://localhost:9200/_template/kibana" -H 'Content-Type: application/json' -d' { "template":".kibana-5.6", "settings":{ "number_of_shards":1 }, "mappings":{ "dashboard":{ "properties":{ "description":{ "type":"string" }, "hits":{ "type":"integer" }, "kibanaSavedObjectMeta":{ "properties":{ "searchSourceJSON":{ "type":"string" } } }, "optionsJSON":{ "type":"string" }, "panelsJSON":{ "type":"string" }, "timeFrom":{ "type":"string" }, "timeRestore":{ "type":"boolean" }, "timeTo":{ "type":"string" }, "title":{ "type":"string" }, "uiStateJSON":{ "type":"string" }, "version":{ "type":"integer" } } }, "_default_":{ "dynamic":"strict" }, "url":{ "dynamic":"strict", "properties":{ "accessCount":{ "type":"long" }, "accessDate":{ "type":"date", "format":"strict_date_optional_time||epoch_millis" }, "createDate":{ "type":"date", "format":"strict_date_optional_time||epoch_millis" }, "url":{ "type":"string", "fields":{ "keyword":{ "type":"string", "index":"not_analyzed", "ignore_above":2048 } }, "fielddata":false } } }, "search":{ "properties":{ "columns":{ "type":"string" }, "description":{ "type":"string" }, "hits":{ "type":"integer" }, "kibanaSavedObjectMeta":{ "properties":{ "searchSourceJSON":{ "type":"string" } } }, "sort":{ "type":"string" }, "title":{ "type":"string" }, "version":{ "type":"integer" } } }, "index-pattern":{ "properties":{ "fieldFormatMap":{ "type":"string" }, "fields":{ "type":"string" }, "timeFieldName":{ "type":"string" }, "title":{ "type":"string" } } }, "server":{ "dynamic":"strict", "properties":{ "uuid":{ "type":"string", "index":"not_analyzed" } } }, "config":{ "properties":{ "buildNum":{ "type":"string", "index":"not_analyzed" }, "defaultIndex":{ "type":"string" }, "discover:aggs:terms:size":{ "type":"long" } } }, "visualization":{ "properties":{ "description":{ "type":"string" }, "kibanaSavedObjectMeta":{ "properties":{ "searchSourceJSON":{ "type":"string" } } }, "savedSearchId":{ "type":"string" }, "title":{ "type":"string" }, "uiStateJSON":{ "type":"string" }, "version":{ "type":"integer" }, "visState":{ "type":"string" } } } } } '
Then, reindex (copy) the values of your old kibana index to the new one :
curl -XPOST "http://localhost:9200/_reindex" -H 'Content-Type: application/json' -d' { "source": { "index": ".kibana" }, "dest": { "index": ".kibana-5.6" } }'
And finally, change your kibana index in /etc/kibana/kibana.yml :
kibana.index: ".kibana-5.6"