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

Respect ignore_above if set for a flattened type field #2248

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.next.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Thanks, you're awesome :-) -->
* Added `container.security_context.privileged` to indicated whether a container was started in privileged mode. #2219, #2225

#### Improvements
* Permit `ignore_above` if explicitly set on a `flattened` field. #2248

#### Deprecated

Expand Down
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