Skip to content

Commit

Permalink
[Fleet] Add support for long and double field type in multi_fields (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski authored Apr 13, 2021
1 parent 356498e commit 971b612
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,64 @@ describe('EPM template', () => {
expect(mappings).toEqual(keywordWithNormalizedMultiFieldsMapping);
});

it('tests processing keyword field with multi fields with long field', () => {
const keywordWithMultiFieldsLiteralYml = `
- name: keywordWithMultiFields
type: keyword
multi_fields:
- name: number_memory_devices
type: long
normalizer: lowercase
`;

const keywordWithMultiFieldsMapping = {
properties: {
keywordWithMultiFields: {
ignore_above: 1024,
type: 'keyword',
fields: {
number_memory_devices: {
type: 'long',
},
},
},
},
};
const fields: Field[] = safeLoad(keywordWithMultiFieldsLiteralYml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields);
expect(mappings).toEqual(keywordWithMultiFieldsMapping);
});

it('tests processing keyword field with multi fields with double field', () => {
const keywordWithMultiFieldsLiteralYml = `
- name: keywordWithMultiFields
type: keyword
multi_fields:
- name: number
type: double
normalizer: lowercase
`;

const keywordWithMultiFieldsMapping = {
properties: {
keywordWithMultiFields: {
ignore_above: 1024,
type: 'keyword',
fields: {
number: {
type: 'double',
},
},
},
},
};
const fields: Field[] = safeLoad(keywordWithMultiFieldsLiteralYml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields);
expect(mappings).toEqual(keywordWithMultiFieldsMapping);
});

it('tests processing object field with no other attributes', () => {
const objectFieldLiteralYml = `
- name: objectField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ function generateMultiFields(fields: Fields): MultiFields {
case 'keyword':
multiFields[f.name] = { ...generateKeywordMapping(f), type: f.type };
break;
case 'long':
multiFields[f.name] = { type: f.type };
break;
case 'double':
multiFields[f.name] = { type: f.type };
break;
}
});
}
Expand Down

0 comments on commit 971b612

Please sign in to comment.