A field not added to custom template

I have tried the custom template, but the field defined was not added. here is what i have done:

  1. define the template jason file as following:
# cat graylog-custom-mapping.json
{
  "template" : "graylog_*",
    "message":{
      "mappings" : {
        "properties" : {
          "xlength" : {
            "type" : "integer",
            "index" : "not_analyzed"
          }
        }
      }
    }
  }
}
  1. load the template to system:
# curl -XPUT -u graylog -d @'graylog-custom-mapping.json' 'https://es1.mylogs.com:9200/_template/graylog-custom-mapping?pretty'
Enter host password for user 'graylog':
{
  "acknowledged" : true
}
  1. check out the new template, and i found the field ‘xlength’ did not add:
# curl -XGET -u graylog 'https://es1.mylogs.com:9200/_template/graylog-custom-mapping?pretty'
Enter host password for user 'graylog':
{
  "graylog-custom-mapping" : {
    "order" : 0,
    "template" : "graylog_*",
    "settings" : { },
    "mappings" : { },
    "aliases" : { }
  }
}

I am using elasticsearch-5.6.7-1 on centos 7.4.

the mapping will only be added to new created indices.

Settings and index mappings in templates are only applied to new indices. After adding, modifying, or deleting an index template, you have to manually rotate the write-active indices of your index sets for the changes to take effect.

http://docs.graylog.org/en/2.4/pages/configuration/elasticsearch.html

I found it was the json file content wrong.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.