[ML] Job validation no longer reports an error when categorization job is properly setup. (#21075)

For categorization jobs, job validation would report that mlcategory isn't an aggregatable field. This fix checks the job configuration and only reports the error if the job config isn't using categorization_field_name and the detector field isn't set to mlcategory.
This commit is contained in:
Walter Rafelsberger 2018-07-23 14:37:16 +02:00 committed by GitHub
parent 7266349e33
commit e503b87eb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 4 deletions

View file

@ -291,6 +291,40 @@ describe('ML - validateJob', () => {
);
});
it('categorization job using mlcategory passes aggregatable field check', () => {
const payload = {
job: {
job_id: 'categorization_test',
analysis_config: {
bucket_span: '15m',
detectors: [{
function: 'count',
by_field_name: 'mlcategory'
}],
categorization_field_name: 'message_text',
influencers: []
},
data_description: { time_field: '@timestamp' },
datafeed_config: { indices: [] }
},
fields: { testField: {} }
};
return validateJob(callWithRequest, payload).then(
(messages) => {
const ids = messages.map(m => m.id);
expect(ids).to.eql([
'job_id_valid',
'detectors_function_not_empty',
'index_fields_valid',
'success_cardinality',
'time_field_invalid',
'influencer_low_suggestion'
]);
}
);
});
// the following two tests validate the correct template rendering of
// urls in messages with {{version}} in them to be replaced with the
// specified version. (defaulting to 'current')

View file

@ -65,10 +65,17 @@ const validateFactory = (callWithRequest, job) => {
});
}
} else {
messages.push({
id: 'field_not_aggregatable',
fieldName: uniqueFieldName
});
// when the job is using categorization and the field name is set to 'mlcategory',
// then don't report the field as not being able to be aggregated.
if (!(
typeof job.analysis_config.categorization_field_name !== 'undefined' &&
uniqueFieldName === 'mlcategory'
)) {
messages.push({
id: 'field_not_aggregatable',
fieldName: uniqueFieldName
});
}
}
});
} catch (e) {