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

[Discover] Show unmapped fields when reading from source #91719

Merged
merged 2 commits into from
Feb 18, 2021
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 @@ -47,6 +47,7 @@ const fieldCounts = {
category: 1,
currency: 1,
customer_birth_date: 1,
unknown_field: 1,
};

describe('group_fields', function () {
Expand Down Expand Up @@ -232,7 +233,7 @@ describe('group_fields', function () {

const actual = groupFields(
fieldsWithUnmappedField as IndexPatternField[],
['customer_birth_date', 'currency', 'unknown'],
['customer_birth_date', 'currency'],
5,
fieldCounts,
fieldFilterState,
Expand All @@ -241,4 +242,30 @@ describe('group_fields', function () {
);
expect(actual.unpopular).toEqual([]);
});

it('includes unmapped fields when reading from source', function () {
const fieldFilterState = getDefaultFieldFilter();
const fieldsWithUnmappedField = [...fields];
fieldsWithUnmappedField.push({
name: 'unknown_field',
type: 'unknown',
esTypes: ['unknown'],
count: 0,
scripted: false,
searchable: false,
aggregatable: false,
readFromDocValues: false,
});

const actual = groupFields(
fieldsWithUnmappedField as IndexPatternField[],
['customer_birth_date', 'currency'],
5,
fieldCounts,
fieldFilterState,
false,
undefined
);
expect(actual.unpopular.map((field) => field.name)).toEqual(['unknown_field']);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export function groupFields(
} else if (field.type !== '_source') {
// do not show unmapped fields unless explicitly specified
// do not add subfields to this list
if ((field.type !== 'unknown' || showUnmappedFields) && !isSubfield) {
if (useNewFieldsApi && (field.type !== 'unknown' || showUnmappedFields) && !isSubfield) {
result.unpopular.push(field);
} else if (!useNewFieldsApi) {
result.unpopular.push(field);
}
}
Expand Down