Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
AWS Opensearch 2.11
Describe the issue:
I get the following error when using dynamic_templates, I’d like to map the fields with k8s.* as text and nested object field network as a flat_object,
{
"error": {
"root_cause": [
{
"type": "class_cast_exception",
"reason": "class_cast_exception: class org.opensearch.index.mapper.TextFieldMapper cannot be cast to class org.opensearch.index.mapper.ObjectMapper (org.opensearch.index.mapper.TextFieldMapper and org.opensearch.index.mapper.ObjectMapper are in unnamed module of loader 'app')"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "class_cast_exception",
"reason": "class_cast_exception: class org.opensearch.index.mapper.TextFieldMapper cannot be cast to class org.opensearch.index.mapper.ObjectMapper (org.opensearch.index.mapper.TextFieldMapper and org.opensearch.index.mapper.ObjectMapper are in unnamed module of loader 'app')"
}
},
"status": 400
}
Configuration:
PUT _index_template/test_logs
{
"index_patterns": [
"test_*"
],
"template": {
"mappings": {
"dynamic_templates": [
{
"k8s_fields": {
"match_pattern": "regex",
"match": "^k8s.*",
"mapping": {
"type": "text"
}
}
},
{
"nested_object_fields": {
"match": "*",
"match_mapping_type": "object",
"mapping": {
"type": "flat_object"
}
}
}
]
}
}
}
PUT test_logs/_doc/1
{
"k8s.application.name": "test-app",
"k8s.container.restart_count": "0",
"k8s.namespace.name": "test",
"k8s.pod.name": "test-app-9f45bf4b-v76fr",
"network": {
"ip_address": "10.10.1.15",
"security_group_id": "sg-111111111111111",
"subnet_id": "subnet-111111111111111",
"vpc_id": "vpc-111111111111111"
}
}
Is something wrong with the regex pattern in the dynamic template?
Relevant Logs or Screenshots: