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

[ML] File data viz fix fields from mappings #77251

Merged
merged 4 commits into from
Sep 15, 2020
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 @@ -26,7 +26,7 @@ export function FieldStatsCard({ field }) {

return (
<EuiPanel hasShadow={false} className="mlFieldDataCard">
<div className="ml-field-data-card">
<div className="ml-field-data-card" data-test-subj="mlPageFileDataVisFieldDataCard">
<div className={`ml-field-title-bar ${type}`}>
<FieldTypeIcon type={type} needsAria={false} />
<div className="field-name" tabIndex="0" aria-label={`${cardTitleAriaLabel.join(', ')}`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ function createFields(results) {
timestamp_field: timestampField,
} = results;

if (mappings && fieldStats) {
if (mappings && mappings.properties && fieldStats) {
const fieldNames = getFieldNames(results);

return fieldNames.map((name) => {
if (fieldStats[name] !== undefined) {
const field = { name };
const f = fieldStats[name];
const m = mappings[name];
const m = mappings.properties[name];

// sometimes the timestamp field is not in the mappings, and so our
// collection of fields will be missing a time field with a type of date
Expand Down Expand Up @@ -93,7 +93,7 @@ function createFields(results) {
// this could be the message field for a semi-structured log file or a
// field which the endpoint has not been able to work out any information for
const type =
mappings[name] && mappings[name].type === ML_JOB_FIELD_TYPES.TEXT
mappings.properties[name] && mappings.properties[name].type === ML_JOB_FIELD_TYPES.TEXT
? ML_JOB_FIELD_TYPES.TEXT
: ML_JOB_FIELD_TYPES.UNKNOWN;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function getFieldNames(results) {
// there may be fields in the mappings which do not exist in the field_stats
// e.g. the message field for a semi-structured log file, as they have no stats.
// add any extra fields to the list
const differenceFields = difference(Object.keys(mappings), tempFields);
const differenceFields = difference(Object.keys(mappings.properties), tempFields);

// except @timestamp
const timestampIndex = differenceFields.indexOf('@timestamp');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function ({ getService }: FtrProviderContext) {
expected: {
results: {
title: 'artificial_server_log',
numberOfFields: 4,
},
},
},
Expand Down Expand Up @@ -62,6 +63,9 @@ export default function ({ getService }: FtrProviderContext) {
await ml.dataVisualizerFileBased.assertFileContentPanelExists();
await ml.dataVisualizerFileBased.assertSummaryPanelExists();
await ml.dataVisualizerFileBased.assertFileStatsPanelExists();
await ml.dataVisualizerFileBased.assertNumberOfFieldCards(
testData.expected.results.numberOfFields
);

await ml.testExecution.logTestStep('loads the import settings page');
await ml.dataVisualizerFileBased.navigateToFileImport();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ export function MachineLearningDataVisualizerFileBasedProvider(
await testSubjects.existOrFail('mlFileDataVisFileStatsPanel');
},

async assertNumberOfFieldCards(number: number) {
const cards = await testSubjects.findAll('mlPageFileDataVisFieldDataCard');
expect(cards.length).to.eql(
number,
`expected ${number} field cards to exist, but found ${cards.length}`
);
},

async assertImportButtonEnabled(expectedValue: boolean) {
const isEnabled = await testSubjects.isEnabled('mlFileDataVisOpenImportPageButton');
expect(isEnabled).to.eql(
Expand Down