Skip to content
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,26 @@ describe('EPM template', () => {
expect(JSON.stringify(mappings)).toEqual(JSON.stringify(constantKeywordMapping));
});

it('tests constant_keyword field type with value', () => {
const constantKeywordLiteralYaml = `
- name: constantKeyword
type: constant_keyword
value: always_the_same
`;
const constantKeywordMapping = {
properties: {
constantKeyword: {
type: 'constant_keyword',
value: 'always_the_same',
},
},
};
const fields: Field[] = safeLoad(constantKeywordLiteralYaml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields);
expect(JSON.stringify(mappings)).toEqual(JSON.stringify(constantKeywordMapping));
});

it('processes meta fields', () => {
const metaFieldLiteralYaml = `
- name: fieldWithMetas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ export function generateMappings(fields: Field[]): IndexTemplateMappings {
fieldProps.fields = generateMultiFields(field.multi_fields);
}
break;
case 'constant_keyword':
fieldProps.type = field.type;
if (field.value) {
fieldProps.value = field.value;
}
break;
case 'object':
fieldProps = { ...fieldProps, ...generateDynamicAndEnabled(field), type: 'object' };
break;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions x-pack/plugins/fleet/server/services/epm/fields/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Field {
name: string;
type?: string;
description?: string;
value?: string;
format?: string;
fields?: Fields;
enabled?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
object_type: integer
- name: invalidarray
type: array
- name: cycle_type
type: constant_keyword
value: bicycle