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

[Fleet] Support dimension mappings in dynamic templates #180023

Merged
merged 2 commits into from
Apr 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,71 @@ describe('EPM template', () => {
expect(mappings).toEqual(runtimeFieldMapping);
});

it('tests processing dimension fields on a dynamic template object', () => {
const textWithRuntimeFieldsLiteralYml = `
- name: labels.*
type: object
object_type: keyword
dimension: true
`;
const runtimeFieldMapping = {
properties: {
labels: {
type: 'object',
dynamic: true,
},
},
dynamic_templates: [
{
'labels.*': {
match_mapping_type: 'string',
path_match: 'labels.*',
mapping: {
type: 'keyword',
time_series_dimension: true,
},
},
},
],
};
const fields: Field[] = safeLoad(textWithRuntimeFieldsLiteralYml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields, true);
expect(mappings).toEqual(runtimeFieldMapping);
});

it('tests processing dimension fields on a dynamic template field', () => {
const textWithRuntimeFieldsLiteralYml = `
- name: labels.*
type: keyword
dimension: true
`;
const runtimeFieldMapping = {
properties: {
labels: {
type: 'object',
dynamic: true,
},
},
dynamic_templates: [
{
'labels.*': {
match_mapping_type: 'string',
path_match: 'labels.*',
mapping: {
type: 'keyword',
time_series_dimension: true,
},
},
},
],
};
const fields: Field[] = safeLoad(textWithRuntimeFieldsLiteralYml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields, true);
expect(mappings).toEqual(runtimeFieldMapping);
});

it('tests processing scaled_float fields in a dynamic template', () => {
const textWithRuntimeFieldsLiteralYml = `
- name: numeric_labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ function _generateMappings(
);
}

if (field.dimension && isIndexModeTimeSeries) {
dynProperties.time_series_dimension = field.dimension;
}

// When a wildcard field specifies the subobjects setting,
// the parent intermediate object should set the subobjects
// setting.
Expand Down
Loading