Skip to content

Commit c5fed5b

Browse files
committed
added missing package field mappings
1 parent c55bb91 commit c5fed5b

2 files changed

Lines changed: 51 additions & 3 deletions

File tree

x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,27 @@ describe('EPM template', () => {
157157
expect(mappings).toEqual(longWithIndexFalseMapping);
158158
});
159159

160+
it('tests processing keyword field with doc_values false', () => {
161+
const keywordWithIndexFalseYml = `
162+
- name: keywordIndexFalse
163+
type: keyword
164+
doc_values: false
165+
`;
166+
const keywordWithIndexFalseMapping = {
167+
properties: {
168+
keywordIndexFalse: {
169+
ignore_above: 1024,
170+
type: 'keyword',
171+
doc_values: false,
172+
},
173+
},
174+
};
175+
const fields: Field[] = safeLoad(keywordWithIndexFalseYml);
176+
const processedFields = processFields(fields);
177+
const mappings = generateMappings(processedFields);
178+
expect(mappings).toEqual(keywordWithIndexFalseMapping);
179+
});
180+
160181
it('tests processing text field with multi fields', () => {
161182
const textWithMultiFieldsLiteralYml = `
162183
- name: textWithMultiFields
@@ -378,6 +399,34 @@ describe('EPM template', () => {
378399
expect(mappings).toEqual(keywordWithMultiFieldsMapping);
379400
});
380401

402+
it('tests processing wildcard field with multi fields with match_only_text type', () => {
403+
const wildcardWithMultiFieldsLiteralYml = `
404+
- name: wildcardWithMultiFields
405+
type: wildcard
406+
multi_fields:
407+
- name: text
408+
type: match_only_text
409+
`;
410+
411+
const wildcardWithMultiFieldsMapping = {
412+
properties: {
413+
wildcardWithMultiFields: {
414+
ignore_above: 1024,
415+
type: 'wildcard',
416+
fields: {
417+
text: {
418+
type: 'match_only_text',
419+
},
420+
},
421+
},
422+
},
423+
};
424+
const fields: Field[] = safeLoad(wildcardWithMultiFieldsLiteralYml);
425+
const processedFields = processFields(fields);
426+
const mappings = generateMappings(processedFields);
427+
expect(mappings).toEqual(wildcardWithMultiFieldsMapping);
428+
});
429+
381430
it('tests processing object field with no other attributes', () => {
382431
const objectFieldLiteralYml = `
383432
- name: objectField

x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,8 @@ function generateMultiFields(fields: Fields): MultiFields {
244244
multiFields[f.name] = { ...generateKeywordMapping(f), type: f.type };
245245
break;
246246
case 'long':
247-
multiFields[f.name] = { type: f.type };
248-
break;
249247
case 'double':
248+
case 'match_only_text':
250249
multiFields[f.name] = { type: f.type };
251250
break;
252251
}
@@ -302,7 +301,7 @@ function getDefaultProperties(field: Field): Properties {
302301
if (field.index !== undefined) {
303302
properties.index = field.index;
304303
}
305-
if (field.doc_values) {
304+
if (field.doc_values !== undefined) {
306305
properties.doc_values = field.doc_values;
307306
}
308307
if (field.copy_to) {

0 commit comments

Comments
 (0)