Skip to content

Commit 4cd381b

Browse files
[ML] Fixes bucket span estimators loading of max_buckets setting (#59639)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent d9ade94 commit 4cd381b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

x-pack/legacy/plugins/ml/server/models/bucket_span_estimator/bucket_span_estimator.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,21 @@ export function estimateBucketSpanFactory(callWithRequest, elasticsearchPlugin,
343343
filterPath: '*.*max_buckets',
344344
})
345345
.then(settings => {
346-
if (typeof settings !== 'object' || typeof settings.defaults !== 'object') {
346+
if (typeof settings !== 'object') {
347+
reject('Unable to retrieve cluster settings');
348+
}
349+
350+
// search.max_buckets could exist in default, persistent or transient cluster settings
351+
const maxBucketsSetting = (settings.defaults ||
352+
settings.persistent ||
353+
settings.transient ||
354+
{})['search.max_buckets'];
355+
356+
if (maxBucketsSetting === undefined) {
347357
reject('Unable to retrieve cluster setting search.max_buckets');
348358
}
349359

350-
const maxBuckets = parseInt(settings.defaults['search.max_buckets']);
360+
const maxBuckets = parseInt(maxBucketsSetting);
351361

352362
const runEstimator = (splitFieldValues = []) => {
353363
const bucketSpanEstimator = new BucketSpanEstimator(

0 commit comments

Comments
 (0)