-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Is your feature request related to a problem? Please describe
This is similar to feature request #11276. I want the behavior of dynamic:false, which drops unknown fields in the mapping, but still allow for templates in dynamic_templates. In practice, many fields rely on both dynamic templates such as date_ or metric_ to support predictable naming patterns. This works in tandem with existing type mappings, with the goal of ignoring unexpected fields instead of raising an error. Currently dynamic:false disables dynamic_templates as well, which makes it impossible to use both at simultaneously.
Describe the solution you'd like
The proposed solution is a new dynamic option called false_allow_templates, which acts as a middle ground dynamic:false and dynamic:true.
Take the following example index setting.
{
"properties": {
"url": { "type": "keyword" },
},
"dynamic": "false_allow_templates",
"dynamic_templates": [
{
"dates": {
"match": "date_*",
"mapping": {
"type": "date",
},
},
}
]
}
An index such as above would create create respective mappings for fields called "url", "date_timezone", "date_timestamp", etc., but it would also ignore other fields that don't match such as "author".
Thus the resulting mapping would be
{
"properties": {
"url": { "type": "keyword" },
"date_timestamp": { "type": "date" },
"date_timezone": { "type": "date" }
}
...
}
Related component
Indexing
Describe alternatives you've considered
I have tried creating a catchall dynamic template using { "match":"*" }. However, this would still include the unknown fields within the index mapping under properties, which does not solve my issue.
I have also tried making an ingest pipeline that uses a script processor to validate the set of fields within a new document. I use a CI pipeline to update the script in the pipeline that is run whenever there is an update to the schema, but this feels inefficient and clunky.
Additional context
No response