Sorry I might not have explain properly
I am talking about creating template
Here is exactly what happens. using your example. it must be some bug or I am doing something wrong
Works - Created template
PUT _index_template/test
{
"index_patterns": ["test*"],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": "1"
},
"mappings": {
"dynamic": "strict",
"properties": {
"@timestamp": {
"type": "date"
},
"number": {
"type": "long"
},
"word": {
"type": "keyword"
}
}
}
}
}
Works - Put one record to index
POST test/_doc/1
{
"number": 5,
"word": "test"
}
Failed as it suppose to fail, because I don't have extrafield define.
works as expected
POST test/_doc/1
{
"number": 5,
"word": "test",
"extrafield": "yes"
}
Now change template to dynamic=true, and added new field called extrafield
PUT _index_template/test
{
"index_patterns": ["test*"],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": "1"
},
"mappings": {
"dynamic": "true",
"properties": {
"@timestamp": {
"type": "date"
},
"number": {
"type": "long"
},
"word": {
"type": "keyword"
},
**"extrafield"**:{
"type": "boolean"
}
}
}
}
}
This should work Right? because I have extrafield define and mapping dynamic = true but it fails
POST test/_doc/1
{
"number": 5,
"word": "test",
"extrafield": "yes"
}
ERROR, Even though dynamic=true.
GET _index_template/test --> this tells me dynamic=true
{
"error" : {
"root_cause" : [
{
"type" : "strict_dynamic_mapping_exception",
"reason" : "mapping set to strict, dynamic introduction of [extrafield] within [_doc] is not allowed"
}
],
"type" : "strict_dynamic_mapping_exception",
"reason" : "mapping set to strict, dynamic introduction of [extrafield] within [_doc] is not allowed"
},
"status" : 400
}