mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Fleet] Support dimension mappings in dynamic templates (#180023)
Add `time_series_dimension: true` to dynamic field mappings defined with `dimension: true`.
This commit is contained in:
parent
cbcd154c31
commit
392ef7b6a2
2 changed files with 69 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue