I have created an index with following mapping:
{
"mappings": {
"_doc": {
"dynamic": "strict",
"properties": {
"created ": {
"type": "date",
"format": "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
}
}
}
}
}
Then I try index a new document as:
PUT test1/_doc/1
{
"created": "2016/01/01"
}
This is resulting in the following error:
{
"error": {
"root_cause": [
{
"type": "strict_dynamic_mapping_exception",
"reason": "mapping set to strict, dynamic introduction of [created] within [_doc] is not allowed"
}
],
"type": "strict_dynamic_mapping_exception",
"reason": "mapping set to strict, dynamic introduction of [created] within [_doc] is not allowed"
},
"status": 400
}
When I change "dynamic": "strict"
to "dynamic": false
then even though the document get indexed but the field doesn't behave like a date field. The range query doesn't work. If I completely remove the dynamic param from mapping then everything works as expected but the requirement is to keep dynamic as strict.
Please explain me why such a behaviour and how it can be solved.