From 178472c33cdb2b76be6a76504b70c73830d7ce07 Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Wed, 7 Nov 2018 17:19:52 +0100 Subject: [PATCH] Fix Painless script used by TSVB It's at the moment unclear if this is a Painless regression (looks like), but this seems to fix it based on testing. I'm doing this change in the 6.5 branch, for a couple of reasons: I tested it in 6.5 only, because master didn't seem to exhibit this issue. And it is not the right fix, if Painless has a true regression. Closes elastic/beats#8957. --- .../server/lib/vis_data/__tests__/helpers/bucket_transform.js | 2 +- .../metrics/server/lib/vis_data/helpers/bucket_transform.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core_plugins/metrics/server/lib/vis_data/__tests__/helpers/bucket_transform.js b/src/core_plugins/metrics/server/lib/vis_data/__tests__/helpers/bucket_transform.js index e0db2422f80b4..96838613a404c 100644 --- a/src/core_plugins/metrics/server/lib/vis_data/__tests__/helpers/bucket_transform.js +++ b/src/core_plugins/metrics/server/lib/vis_data/__tests__/helpers/bucket_transform.js @@ -437,7 +437,7 @@ describe('bucketTransform', () => { }, gap_policy: 'skip', script: { - source: 'params.value > 0 ? params.value : 0', + source: 'if (params.value > 0) {return params.value} else return 0', lang: 'painless' } } diff --git a/src/core_plugins/metrics/server/lib/vis_data/helpers/bucket_transform.js b/src/core_plugins/metrics/server/lib/vis_data/helpers/bucket_transform.js index ce061464cc994..ba7fa97416161 100644 --- a/src/core_plugins/metrics/server/lib/vis_data/helpers/bucket_transform.js +++ b/src/core_plugins/metrics/server/lib/vis_data/helpers/bucket_transform.js @@ -246,7 +246,7 @@ export default { value: getBucketsPath(bucket.field, metrics), }, script: { - source: 'params.value > 0 ? params.value : 0', + source: 'if (params.value > 0) {return params.value} else return 0', lang: 'painless', }, gap_policy: 'skip', // seems sane