Skip to content

Commit

Permalink
[1.x] Conditional handling in es_template.template_settings (#1191) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ebeahan authored Dec 14, 2020
1 parent 0e94d2d commit 7857351
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scripts/generators/es_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,23 @@ def template_settings(es_version, ecs_version, mappings_section, template_settin
es6_type_fallback(mappings_section['properties'])

# error.stack_trace needs special handling to set
# index: false and doc_values: false
error_stack_trace_mappings = mappings_section['properties']['error']['properties']['stack_trace']
error_stack_trace_mappings.setdefault('index', False)
error_stack_trace_mappings.setdefault('doc_values', False)
# index: false and doc_values: false if the field
# is present in the mappings
try:
error_stack_trace_mappings = mappings_section['properties']['error']['properties']['stack_trace']
error_stack_trace_mappings.setdefault('index', False)
error_stack_trace_mappings.setdefault('doc_values', False)
except KeyError:
pass

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')
# if present
if '_meta' in template:
mappings_section['_meta'] = template.pop('_meta')

return template

Expand Down

0 comments on commit 7857351

Please sign in to comment.