in scripts/generators/es_template.py [0:0]
def entry_for(field: Field) -> Dict:
field_entry: Dict = {'type': field['type']}
try:
if field['type'] == 'object' or field['type'] == 'nested':
if 'enabled' in field and not field['enabled']:
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['enabled'])
# the index field is only valid for field types that are not object and nested
elif 'index' in field and not field['index']:
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['index', 'doc_values'])
if field['type'] == 'keyword' or field['type'] == 'flattened':
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['ignore_above', 'synthetic_source_keep'])
elif field['type'] == 'constant_keyword':
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['value'])
elif field['type'] == 'text':
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['norms'])
elif field['type'] == 'alias':
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['path'])
elif field['type'] == 'scaled_float':
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['scaling_factor'])
if 'multi_fields' in field:
field_entry['fields'] = {}
for mf in field['multi_fields']:
mf_type = mf['type']
mf_entry = {'type': mf_type}
if mf_type == 'keyword':
ecs_helpers.dict_copy_existing_keys(mf, mf_entry, ['normalizer', 'ignore_above'])
elif mf_type == 'text':
ecs_helpers.dict_copy_existing_keys(mf, mf_entry, ['norms', 'analyzer'])
if 'parameters' in mf:
mf_entry.update(mf['parameters'])
field_entry['fields'][mf['name']] = mf_entry
if 'parameters' in field:
field_entry.update(field['parameters'])
except KeyError as ex:
print("Exception {} occurred for field {}".format(ex, field))
raise ex
return field_entry