Skip to content

Commit

Permalink
[Fleet] Support dimension mappings in dynamic templates (#180023)
Browse files Browse the repository at this point in the history
Add `time_series_dimension: true` to dynamic field mappings defined with
`dimension: true`.
  • Loading branch information
jsoriano authored Apr 5, 2024
1 parent cbcd154 commit 392ef7b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
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

0 comments on commit 392ef7b

Please sign in to comment.