Search code examples
elasticsearchdynamicfieldlogstashmappings

Cannot turn Elasticsearch dynamic mapping on


I disabled dynamic mapping with

curl -XPUT 'localhost:9200/_template/template_all?pretty' -H 'Content-Type: application/json' -d' {  "template": "*",  "order":0,  "settings": {    "index.mapper.dynamic": false   }}'

I wanted to turn it back on with

curl -XPUT 'localhost:9200/_template/template_all?pretty' -H 'Content-Type: application/json' -d' {  "template": "*",  "order":0,  "settings": {    "index.mapper.dynamic": true   }}'

It has confirmed it as true, but when I try to have logstash send information to it, in logstash error logs I get back-

"reason"=>"trying to auto create mapping, but dynamic mapping is disabled"

How do I actually turn dynamic mapping back on?


Solution

  • Looks like index for logstash was created with old template (before you update template). Because when you update you template only new indexes will have updated mapping and settings.

    Check is index exists:

    curl -XGET 'localhost:9200/LOGSTASH_INDEX_NAME_HERE'
    

    If index exists and you can delete this index - do it. After this when logstash will try to send something - index will be created with the new mapping.