Skip to content

Commit 00fe629

Browse files
author
Mathieu Martin
committed
Move _meta section back inside mappings, in legacy templates. (elastic#1186)
This fixes an issue introduced by elastic#1156, discovered in elastic#1180. Composable templates support `_meta` at the template's root, but legacy templates don't. So we're just putting it back inside the mappings for legacy templates. This also fixes missing updates to the component template, after the introduction of wildcard in elastic#1098.
1 parent ef6c903 commit 00fe629

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

CHANGELOG.next.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Thanks, you're awesome :-) -->
3030

3131
#### Added
3232

33-
* Added component templates for ECS field sets. #1156
33+
* Added component templates for ECS field sets. #1156, #1186
3434

3535
#### Improvements
3636

experimental/generated/elasticsearch/7/template.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"_meta": {
3-
"version": "1.7.0+exp"
4-
},
52
"index_patterns": [
63
"try-ecs-*"
74
],
85
"mappings": {
6+
"_meta": {
7+
"version": "1.7.0+exp"
8+
},
99
"date_detection": false,
1010
"dynamic_templates": [
1111
{

generated/elasticsearch/6/template.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"_meta": {
3-
"version": "1.7.0"
4-
},
52
"index_patterns": [
63
"try-ecs-*"
74
],
85
"mappings": {
96
"_doc": {
7+
"_meta": {
8+
"version": "1.7.0"
9+
},
1010
"date_detection": false,
1111
"dynamic_templates": [
1212
{

generated/elasticsearch/7/template.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"_meta": {
3-
"version": "1.7.0"
4-
},
52
"index_patterns": [
63
"try-ecs-*"
74
],
85
"mappings": {
6+
"_meta": {
7+
"version": "1.7.0"
8+
},
99
"date_detection": false,
1010
"dynamic_templates": [
1111
{

scripts/generators/es_template.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,15 @@ def template_settings(es_version, ecs_version, mappings_section, template_settin
184184
template = json.load(f)
185185
else:
186186
template = default_template_settings(ecs_version)
187+
187188
if es_version == 6:
188189
template['mappings'] = {'_doc': mappings_section}
189190
else:
190191
template['mappings'] = mappings_section
192+
193+
# _meta can't be at template root in legacy templates, so moving back to mappings section
194+
mappings_section['_meta'] = template.pop('_meta')
195+
191196
return template
192197

193198

0 commit comments

Comments
 (0)