diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js index d587f83a50b5e..8870f04f498d0 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/edit_job_flyout/edit_utils.js @@ -104,6 +104,14 @@ function extractMML(job, newJobData) { if (mml !== job.analysis_limits.model_memory_limit) { mmlData.analysis_limits = { model_memory_limit: mml, + // work around for issue in es where categorization_examples_limit will be reset to the default value + // if it is not included in the update request + // https://github.com/elastic/elasticsearch/issues/108068 + ...(job.analysis_limits.categorization_examples_limit !== undefined + ? { + categorization_examples_limit: job.analysis_limits.categorization_examples_limit, + } + : {}), }; } } diff --git a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts index 75eed3900950c..c7eda482aafad 100644 --- a/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts +++ b/x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts @@ -21,6 +21,7 @@ import { } from '@kbn/ml-anomaly-utils'; import type { RuntimeMappings } from '@kbn/ml-runtime-field-utils'; import type { SavedSearch } from '@kbn/saved-search-plugin/public'; +import { isPopulatedObject } from '@kbn/ml-is-populated-object'; import type { IndexPatternTitle } from '../../../../../../common/types/kibana'; import { getQueryFromSavedSearchObject } from '../../../../util/index_utils'; import type { @@ -327,11 +328,18 @@ export class JobCreator { public set modelMemoryLimit(mml: string | null) { if (mml !== null) { - this._job_config.analysis_limits = { - model_memory_limit: mml, - }; + if (this._job_config.analysis_limits === undefined) { + this._job_config.analysis_limits = {}; + } + this._job_config.analysis_limits.model_memory_limit = mml; } else { - delete this._job_config.analysis_limits; + if (this._job_config.analysis_limits !== undefined) { + delete this._job_config.analysis_limits.model_memory_limit; + + if (isPopulatedObject(this._job_config.analysis_limits) === false) { + delete this._job_config.analysis_limits; + } + } } }