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
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