Skip to content

Commit

Permalink
Move _meta section back inside mappings, in legacy templates. (elasti…
Browse files Browse the repository at this point in the history
…c#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.
  • Loading branch information
Mathieu Martin committed Dec 10, 2020
1 parent ef6c903 commit 00fe629
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.next.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions experimental/generated/elasticsearch/7/template.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down
6 changes: 3 additions & 3 deletions generated/elasticsearch/6/template.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down
6 changes: 3 additions & 3 deletions generated/elasticsearch/7/template.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"_meta": {
"version": "1.7.0"
},
"index_patterns": [
"try-ecs-*"
],
"mappings": {
"_meta": {
"version": "1.7.0"
},
"date_detection": false,
"dynamic_templates": [
{
Expand Down
5 changes: 5 additions & 0 deletions scripts/generators/es_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 00fe629

Please sign in to comment.