Skip to content

Dynamic templates being replaced instead of appending #24853

@nemonster

Description

@nemonster

Elasticsearch version: 5.x (5.0 -5.4)

Plugins installed: none

JVM version (java -version): 1.8.0_11

OS version (uname -a if on a Unix-like system): Darwin Kernel Version 15.6.0: Tue Apr 11 16:00:51 PDT 2017; root:xnu-3248.60.11.5.3~1/RELEASE_X86_64 x86_64

Steps to reproduce:
Took a simple dynamic template example from the Definitive Guide and broke it into two parts. Created the index with one, and then submitted the other one subsequently.

http://localhost:9200/my_index
{
  "mappings": {
    "my_type": {
        "dynamic_templates": [
            { "es": {
                  "match":              "*_es", 
                  "match_mapping_type": "string",
                  "mapping": {
                      "type":           "string",
                      "analyzer":       "spanish"
                  }
            }}
        ]
}}}

http://localhost:9200/my_index/_mappings/my_type
{
  "dynamic_templates": [
    { "en": {
          "match":              "*", 
          "match_mapping_type": "string",
          "mapping": {
              "type":           "string",
              "analyzer":       "english"
          }
    }}
  ]
}

In 2.2 when you check the mapping you see:

{
  "my_index" : {
    "mappings" : {
      "my_type" : {
        "dynamic_templates" : [ {
          "es" : {
            "mapping" : {
              "analyzer" : "spanish",
              "type" : "string"
            },
            "match" : "*_es",
            "match_mapping_type" : "string"
          }
        }, {
          "en" : {
            "mapping" : {
              "type" : "string",
              "analyzer" : "english"
            },
            "match" : "*",
            "match_mapping_type" : "string"
          }
        }
        } ]
      }
    }
  }
}

However when executing exactly the same steps in 5.x you get:

{
  "my_index" : {
    "mappings" : {
      "my_type" : {
        "dynamic_templates" : [
          {
            "en" : {
              "match" : "*",
              "match_mapping_type" : "string",
              "mapping" : {
                "analyzer" : "english",
                "type" : "string"
              }
            }
          }
        ]
      }
    }
  }
}

It doesn't appear to be appending new templates to the mapping, but replacing any existing ones, despite the documentation being the same between 2.2 and 5.x.

Metadata

Metadata

Assignees

Labels

:Search Foundations/MappingIndex mappings, including merging and defining field types>breaking>docsGeneral docs changesTeam:Search FoundationsMeta label for the Search Foundations team in Elasticsearch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions