From 809a905f89ad9fd5823fee580520c1044569cf03 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Wed, 10 Nov 2021 16:12:17 +0300 Subject: [PATCH] [Timelion ]Remove usage of ignore_throttled unless targeting frozen indices to avoid deprecation warning (#118022) * [Timelion ]Remove usage of ignore_throttled unless targeting frozen indices to avoid deprecation warning Part of: #117980 * add tests --- .../timelion/server/series_functions/es/es.test.js | 12 ++++++++++-- .../server/series_functions/es/lib/build_request.js | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/plugins/vis_types/timelion/server/series_functions/es/es.test.js b/src/plugins/vis_types/timelion/server/series_functions/es/es.test.js index f55ee31f39799..9c0dac6f6975a 100644 --- a/src/plugins/vis_types/timelion/server/series_functions/es/es.test.js +++ b/src/plugins/vis_types/timelion/server/series_functions/es/es.test.js @@ -256,12 +256,20 @@ describe('es', () => { sandbox.restore(); }); - test('sets ignore_throttled=true on the request', () => { + test('sets ignore_throttled=false on the request', () => { + config.index = 'beer'; + tlConfig.settings[UI_SETTINGS.SEARCH_INCLUDE_FROZEN] = true; + const request = fn(config, tlConfig, emptyScriptFields); + + expect(request.params.ignore_throttled).toEqual(false); + }); + + test('sets no ignore_throttled if SEARCH_INCLUDE_FROZEN is false', () => { config.index = 'beer'; tlConfig.settings[UI_SETTINGS.SEARCH_INCLUDE_FROZEN] = false; const request = fn(config, tlConfig, emptyScriptFields); - expect(request.params.ignore_throttled).toEqual(true); + expect(request.params).not.toHaveProperty('ignore_throttled'); }); test('sets no timeout if elasticsearch.shardTimeout is set to 0', () => { diff --git a/src/plugins/vis_types/timelion/server/series_functions/es/lib/build_request.js b/src/plugins/vis_types/timelion/server/series_functions/es/lib/build_request.js index 20e3f71801854..99b5d0bacd858 100644 --- a/src/plugins/vis_types/timelion/server/series_functions/es/lib/build_request.js +++ b/src/plugins/vis_types/timelion/server/series_functions/es/lib/build_request.js @@ -66,9 +66,10 @@ export default function buildRequest(config, tlConfig, scriptFields, runtimeFiel _.assign(aggCursor, createDateAgg(config, tlConfig, scriptFields)); + const includeFrozen = Boolean(tlConfig.settings[UI_SETTINGS.SEARCH_INCLUDE_FROZEN]); const request = { index: config.index, - ignore_throttled: !tlConfig.settings[UI_SETTINGS.SEARCH_INCLUDE_FROZEN], + ...(includeFrozen ? { ignore_throttled: false } : {}), body: { query: { bool: bool,