Skip to content

Using same key in dynamic template leads to overwrites #2693

@simioa

Description

@simioa

Hi,

I don't know if this is rather a general elasticsearch issue but I found this "bug" in the apm-server Index template.

The dynamic_templates section in the exported Index Template contains objects with the same key which leads to overwrites rather than appends in the final Index Mapping.

The apm-server Index template contains the following definitions when exported with the apm-server export template command. Used version here is 6.8.2

        {
          "context.tags": {
            "mapping": {
              "type": "keyword"
            },
            "match_mapping_type": "string",
            "path_match": "context.tags.*"
          }
        },
        {
          "context.tags": {
            "mapping": {
              "type": "boolean"
            },
            "match_mapping_type": "boolean",
            "path_match": "context.tags.*"
          }
        },
        {
          "context.tags": {
            "mapping": {
              "scaling_factor": 1000000,
              "type": "scaled_float"
            },
            "match_mapping_type": "*",
            "path_match": "context.tags.*"
          }
        },

Those three definitions share the same "context.tags" key
When deployed and a Index is created with this template, only the last "context.tags" definition is contained in the Index Mapping, which leads to indexing failures when the field value is not a float

Renaming the keys to unique values as a workaround seems to fix this.

In the 7.x Index Template context.tags is replaced by labels which seems to have the same issue (not tested)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions