diff --git a/CHANGELOG.next.md b/CHANGELOG.next.md index 5176db9d09..ca4fa584a4 100644 --- a/CHANGELOG.next.md +++ b/CHANGELOG.next.md @@ -30,7 +30,7 @@ Thanks, you're awesome :-) --> #### Added -* Added component templates for ECS field sets. #1156 +* Added component templates for ECS field sets. #1156, #1186 #### Improvements diff --git a/experimental/generated/elasticsearch/7/template.json b/experimental/generated/elasticsearch/7/template.json index 8ebea814f1..7e95828a42 100644 --- a/experimental/generated/elasticsearch/7/template.json +++ b/experimental/generated/elasticsearch/7/template.json @@ -1,11 +1,11 @@ { - "_meta": { - "version": "1.7.0+exp" - }, "index_patterns": [ "try-ecs-*" ], "mappings": { + "_meta": { + "version": "1.7.0+exp" + }, "date_detection": false, "dynamic_templates": [ { diff --git a/generated/elasticsearch/6/template.json b/generated/elasticsearch/6/template.json index 86990630de..62c033e096 100644 --- a/generated/elasticsearch/6/template.json +++ b/generated/elasticsearch/6/template.json @@ -1,12 +1,12 @@ { - "_meta": { - "version": "1.7.0" - }, "index_patterns": [ "try-ecs-*" ], "mappings": { "_doc": { + "_meta": { + "version": "1.7.0" + }, "date_detection": false, "dynamic_templates": [ { diff --git a/generated/elasticsearch/7/template.json b/generated/elasticsearch/7/template.json index b3e998015f..8341531f01 100644 --- a/generated/elasticsearch/7/template.json +++ b/generated/elasticsearch/7/template.json @@ -1,11 +1,11 @@ { - "_meta": { - "version": "1.7.0" - }, "index_patterns": [ "try-ecs-*" ], "mappings": { + "_meta": { + "version": "1.7.0" + }, "date_detection": false, "dynamic_templates": [ { diff --git a/scripts/generators/es_template.py b/scripts/generators/es_template.py index b221cb5531..81e35e5d6e 100644 --- a/scripts/generators/es_template.py +++ b/scripts/generators/es_template.py @@ -184,10 +184,15 @@ def template_settings(es_version, ecs_version, mappings_section, template_settin template = json.load(f) else: template = default_template_settings(ecs_version) + if es_version == 6: template['mappings'] = {'_doc': mappings_section} else: template['mappings'] = mappings_section + + # _meta can't be at template root in legacy templates, so moving back to mappings section + mappings_section['_meta'] = template.pop('_meta') + return template