Skip to content

Commit

Permalink
added missing package field mappings (#128391)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic authored Mar 24, 2022
1 parent f289a5d commit 0695df6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ describe('EPM template', () => {
expect(mappings).toEqual(longWithIndexFalseMapping);
});

it('tests processing keyword field with doc_values false', () => {
const keywordWithIndexFalseYml = `
- name: keywordIndexFalse
type: keyword
doc_values: false
`;
const keywordWithIndexFalseMapping = {
properties: {
keywordIndexFalse: {
ignore_above: 1024,
type: 'keyword',
doc_values: false,
},
},
};
const fields: Field[] = safeLoad(keywordWithIndexFalseYml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields);
expect(mappings).toEqual(keywordWithIndexFalseMapping);
});

it('tests processing text field with multi fields', () => {
const textWithMultiFieldsLiteralYml = `
- name: textWithMultiFields
Expand Down Expand Up @@ -378,6 +399,34 @@ describe('EPM template', () => {
expect(mappings).toEqual(keywordWithMultiFieldsMapping);
});

it('tests processing wildcard field with multi fields with match_only_text type', () => {
const wildcardWithMultiFieldsLiteralYml = `
- name: wildcardWithMultiFields
type: wildcard
multi_fields:
- name: text
type: match_only_text
`;

const wildcardWithMultiFieldsMapping = {
properties: {
wildcardWithMultiFields: {
ignore_above: 1024,
type: 'wildcard',
fields: {
text: {
type: 'match_only_text',
},
},
},
},
};
const fields: Field[] = safeLoad(wildcardWithMultiFieldsLiteralYml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields);
expect(mappings).toEqual(wildcardWithMultiFieldsMapping);
});

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 @@ -244,9 +244,8 @@ function generateMultiFields(fields: Fields): MultiFields {
multiFields[f.name] = { ...generateKeywordMapping(f), type: f.type };
break;
case 'long':
multiFields[f.name] = { type: f.type };
break;
case 'double':
case 'match_only_text':
multiFields[f.name] = { type: f.type };
break;
}
Expand Down Expand Up @@ -302,7 +301,7 @@ function getDefaultProperties(field: Field): Properties {
if (field.index !== undefined) {
properties.index = field.index;
}
if (field.doc_values) {
if (field.doc_values !== undefined) {
properties.doc_values = field.doc_values;
}
if (field.copy_to) {
Expand Down

0 comments on commit 0695df6

Please sign in to comment.