Skip to content

Commit

Permalink
respect ignore_above if set for a flattened type field
Browse files Browse the repository at this point in the history
  • Loading branch information
ebeahan committed Aug 4, 2023
1 parent 630429e commit 883b618
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/generators/es_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def entry_for(field: Field) -> Dict:
elif 'index' in field and not field['index']:
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['index', 'doc_values'])

if field['type'] == 'keyword':
if field['type'] == 'keyword' or field['type'] == 'flattened':
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['ignore_above'])
elif field['type'] == 'constant_keyword':
ecs_helpers.dict_copy_existing_keys(field, field_entry, ['value'])
Expand Down
38 changes: 38 additions & 0 deletions scripts/tests/test_es_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,44 @@ def test_constant_keyword_no_value(self):
exp = {'type': 'constant_keyword'}
self.assertEqual(es_template.entry_for(test_map), exp)

def test_keyword_pass_ignore_above(self):
test_map = {
'name': 'field_with_ignore_above_set',
'type': 'keyword',
'ignore_above': 1024
}

exp = {
'type': 'keyword',
'ignore_above': 1024
}
self.assertEqual(es_template.entry_for(test_map), exp)

def test_flattened_pass_ignore_above(self):
test_map = {
'name': 'field_with_ignore_above_set',
'type': 'flattened',
'ignore_above': 1024
}

exp = {
'type': 'flattened',
'ignore_above': 1024
}
self.assertEqual(es_template.entry_for(test_map), exp)

def test_other_types_not_pass_ignore_above(self):
test_map = {
'name': 'field_should_not_have_ignore_above_set',
'type': 'text',
'ignore_above': 1024
}

exp = {
'type': 'text'
}
self.assertEqual(es_template.entry_for(test_map), exp)

def test_parameters(self):
test_map = {
'name': 'field_with_parameters',
Expand Down

0 comments on commit 883b618

Please sign in to comment.