From 0baeed2ca7e58ac83f017acb7506ea56e36ee0d7 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 30 Nov 2021 11:04:57 +0100 Subject: [PATCH] specify date format for time split filters (#119504) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- src/plugins/data/common/search/aggs/agg_configs.test.ts | 2 ++ src/plugins/data/common/search/aggs/agg_configs.ts | 1 + src/plugins/data/common/search/aggs/utils/time_splits.ts | 1 + 3 files changed, 4 insertions(+) diff --git a/src/plugins/data/common/search/aggs/agg_configs.test.ts b/src/plugins/data/common/search/aggs/agg_configs.test.ts index 104cd3b2815bc..80e5a079cfd59 100644 --- a/src/plugins/data/common/search/aggs/agg_configs.test.ts +++ b/src/plugins/data/common/search/aggs/agg_configs.test.ts @@ -360,6 +360,7 @@ describe('AggConfigs', () => { "0": Object { "range": Object { "@timestamp": Object { + "format": "strict_date_optional_time", "gte": "2021-05-05T00:00:00.000Z", "lte": "2021-05-10T00:00:00.000Z", }, @@ -368,6 +369,7 @@ describe('AggConfigs', () => { "86400000": Object { "range": Object { "@timestamp": Object { + "format": "strict_date_optional_time", "gte": "2021-05-04T00:00:00.000Z", "lte": "2021-05-09T00:00:00.000Z", }, diff --git a/src/plugins/data/common/search/aggs/agg_configs.ts b/src/plugins/data/common/search/aggs/agg_configs.ts index 9a362466c0fd7..a022abba7fb45 100644 --- a/src/plugins/data/common/search/aggs/agg_configs.ts +++ b/src/plugins/data/common/search/aggs/agg_configs.ts @@ -406,6 +406,7 @@ export class AggConfigs { .map(([filter, field]) => ({ range: { [field]: { + format: 'strict_date_optional_time', gte: moment(filter?.query.range[field].gte).subtract(shift).toISOString(), lte: moment(filter?.query.range[field].lte).subtract(shift).toISOString(), }, diff --git a/src/plugins/data/common/search/aggs/utils/time_splits.ts b/src/plugins/data/common/search/aggs/utils/time_splits.ts index c4a603a383e38..2eb49d76c6082 100644 --- a/src/plugins/data/common/search/aggs/utils/time_splits.ts +++ b/src/plugins/data/common/search/aggs/utils/time_splits.ts @@ -430,6 +430,7 @@ export function insertTimeShiftSplit( filters[key] = { range: { [timeField]: { + format: 'strict_date_optional_time', gte: moment(timeFilter.query.range[timeField].gte).subtract(shift).toISOString(), lte: moment(timeFilter.query.range[timeField].lte).subtract(shift).toISOString(), },