Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Conditional handling in es_template.template_settings (#1191) #1192

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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