I'm testing implementing multiple dynamic templates on 3 different fields but each time mapping is not getting created correctly. Only the first array object template is picked up. Any help would be great on what is wrong or any alternative way to achieve this. Need different objects to have different dynamic mappings, some are root level and some are inner objects.
Mapping:
PUT /test-dy
{
"mappings": {
"dynamic": "strict",
"dynamic_templates": [
{
"default": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
},
{
"custom_field1": {
"path_match": "fld1.*",
"match_mapping_type": "string",
"mapping": {
"type": "text",
"fields": {
"keyword": {"type": "keyword"}
}
}
}
},
{
"custom_field2": {
"path_match": "fld2.*",
"match_mapping_type": "string",
"mapping": {
"type": "text"
}
}
},
{
"custom_field3": {
"path_match": "fld3.profile.*",
"match_mapping_type": "string",
"mapping": {
"type": "text"
}
}
}
],
"properties": {
"fld1": {"type": "object", "dynamic": "true"},
"fld2": {"type": "object", "dynamic": "true"},
"fld3": {"type": "object", "properties":{
"name":{"type": "text"},
"profile":{"type": "nested", "dynamic": "true"}
}},
"fld4": {"type": "text"}
}
}
}
Mock data:
PUT test-dy/_doc/1
{
"fld1": {
"key1":"val1",
"key2":"val2"
},
"fld2": {
"key1":"val1",
"profile":{
"subkey1":"val1",
"subkey2": ["val1"]
}
},
"fld3": {
"name":"xxx",
"profile":[{
"subkey1":"val1",
"subkey2": ["val1"]
}]
},
"fld4": "hello hi"
}