[Fleet] Don't ignore "index: false" in integration index template (#110234)

* fix: don't ignore index prop when falsey

* test: add unit test for index false
This commit is contained in:
Mark Hopkin 2021-08-26 16:47:11 +01:00 committed by GitHub
parent 602392e88d
commit 2a05ec9ff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -174,6 +174,26 @@ describe('EPM template', () => {
expect(template).toMatchSnapshot(path.basename(ymlPath));
});
it('tests processing long field with index false', () => {
const longWithIndexFalseYml = `
- name: longIndexFalse
type: long
index: false
`;
const longWithIndexFalseMapping = {
properties: {
longIndexFalse: {
type: 'long',
index: false,
},
},
};
const fields: Field[] = safeLoad(longWithIndexFalseYml);
const processedFields = processFields(fields);
const mappings = generateMappings(processedFields);
expect(mappings).toEqual(longWithIndexFalseMapping);
});
it('tests processing text field with multi fields', () => {
const textWithMultiFieldsLiteralYml = `
- name: textWithMultiFields

View file

@ -277,7 +277,7 @@ function generateTextMapping(field: Field): IndexTemplateMapping {
function getDefaultProperties(field: Field): Properties {
const properties: Properties = {};
if (field.index) {
if (field.index !== undefined) {
properties.index = field.index;
}
if (field.doc_values) {