From 62a043c4fead08d1a074e6a9db22ccb64c5c8bef Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Mon, 9 Mar 2020 14:43:23 +0000 Subject: [PATCH] [ML] Fixes bucket span estimators loading of max_buckets setting (#59639) Co-authored-by: Elastic Machine --- .../bucket_span_estimator/bucket_span_estimator.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.js b/x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.js index 53b9d75304963..d2e4311bf6f22 100644 --- a/x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.js +++ b/x-pack/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.js @@ -343,11 +343,21 @@ export function estimateBucketSpanFactory( filterPath: '*.*max_buckets', }) .then(settings => { - if (typeof settings !== 'object' || typeof settings.defaults !== 'object') { + if (typeof settings !== 'object') { + reject('Unable to retrieve cluster settings'); + } + + // search.max_buckets could exist in default, persistent or transient cluster settings + const maxBucketsSetting = (settings.defaults || + settings.persistent || + settings.transient || + {})['search.max_buckets']; + + if (maxBucketsSetting === undefined) { reject('Unable to retrieve cluster setting search.max_buckets'); } - const maxBuckets = parseInt(settings.defaults['search.max_buckets']); + const maxBuckets = parseInt(maxBucketsSetting); const runEstimator = (splitFieldValues = []) => { const bucketSpanEstimator = new BucketSpanEstimator(