mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Fixing various issues when cloning a job using a wizard (#23368)
This commit is contained in:
parent
e8bebedf8c
commit
ec49c36cbb
3 changed files with 25 additions and 7 deletions
|
@ -43,7 +43,7 @@ function populateSingleMetricSettings(jobSettings, scope) {
|
|||
if (f.agg !== undefined) {
|
||||
// find the aggregation object in the aggTypeOptions list which has the same name
|
||||
// as the agg setting in the url
|
||||
const agg = scope.ui.aggTypeOptions.find(o => (o.name === f.agg));
|
||||
const agg = scope.ui.aggTypeOptions.find(o => (o.mlName === f.agg));
|
||||
if (agg !== undefined) {
|
||||
scope.formConfig.agg.type = agg;
|
||||
scope.aggChange();
|
||||
|
@ -83,7 +83,7 @@ function populateMultiMetricSettings(jobSettings, scope) {
|
|||
}
|
||||
|
||||
if (f.agg !== undefined) {
|
||||
const agg = scope.ui.aggTypeOptions.find(o => (o.name === f.agg));
|
||||
const agg = scope.ui.aggTypeOptions.find(o => (o.mlName === f.agg));
|
||||
if (agg !== undefined) {
|
||||
scope.formConfig.fields[field.id].agg.type = agg;
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ function populatePopulationSettings(jobSettings, scope) {
|
|||
if (field !== undefined) {
|
||||
|
||||
if (f.agg !== undefined) {
|
||||
const agg = scope.ui.aggTypeOptions.find(o => (o.name === f.agg));
|
||||
const agg = scope.ui.aggTypeOptions.find(o => (o.mlName === f.agg));
|
||||
if (agg !== undefined) {
|
||||
field.agg = { type: agg };
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ export function jobSettingsFromJob(job, aggTypeOptions) {
|
|||
|
||||
function getKibanaAggName(mlAggName) {
|
||||
const agg = aggTypeOptions.find(a => a.mlName === mlAggName);
|
||||
return (agg) ? agg.name : undefined;
|
||||
return (agg) ? agg.mlName : undefined;
|
||||
}
|
||||
|
||||
const jobSettings = {};
|
||||
|
@ -43,7 +43,19 @@ export function jobSettingsFromJob(job, aggTypeOptions) {
|
|||
if (job.custom_settings.created_by === WIZARD_TYPE.SINGLE_METRIC) {
|
||||
// single metric
|
||||
const d = dtrs[0];
|
||||
const field = { agg: getKibanaAggName(d.function, aggTypeOptions) };
|
||||
let func = d.function;
|
||||
|
||||
// distinct_count jobs in single metric wizard use a particular aggregation where
|
||||
// the detector function is replaced as non_zero_count.
|
||||
// here we look for this exact situation and switch the function back to distinct_count
|
||||
if (
|
||||
func === 'non_zero_count' &&
|
||||
job.analysis_config.summary_count_field_name !== undefined &&
|
||||
job.analysis_config.summary_count_field_name.match(/^dc_.+/)) {
|
||||
func = 'distinct_count';
|
||||
}
|
||||
|
||||
const field = { agg: getKibanaAggName(func) };
|
||||
if (d.field_name) {
|
||||
field.fieldName = d.field_name;
|
||||
}
|
||||
|
@ -58,7 +70,7 @@ export function jobSettingsFromJob(job, aggTypeOptions) {
|
|||
splitField = d.partition_field_name;
|
||||
}
|
||||
|
||||
const field = { agg: getKibanaAggName(d.function, aggTypeOptions) };
|
||||
const field = { agg: getKibanaAggName(d.function) };
|
||||
if (d.field_name) {
|
||||
field.fieldName = d.field_name;
|
||||
}
|
||||
|
@ -79,7 +91,7 @@ export function jobSettingsFromJob(job, aggTypeOptions) {
|
|||
overField = d.over_field_name;
|
||||
}
|
||||
|
||||
const field = { agg: getKibanaAggName(d.function, aggTypeOptions) };
|
||||
const field = { agg: getKibanaAggName(d.function) };
|
||||
if (d.field_name) {
|
||||
field.fieldName = d.field_name;
|
||||
}
|
||||
|
|
|
@ -548,6 +548,12 @@ class JobService {
|
|||
}
|
||||
}
|
||||
|
||||
// when jumping from a wizard to the advanced job creation,
|
||||
// the wizard's created_by information should be stripped.
|
||||
if (tempJob.custom_settings && tempJob.custom_settings.created_by) {
|
||||
delete tempJob.custom_settings.created_by;
|
||||
}
|
||||
|
||||
return tempJob;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue