Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] added missing package field mappings #128391

Merged
merged 1 commit into from
Mar 24, 2022
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 @@ -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':
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
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