mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Vega] Replacing the 'interval' property should only happen for the date_histogram aggregation (#115001)
This commit is contained in:
parent
00db6023e6
commit
0fa440abad
2 changed files with 18 additions and 6 deletions
|
@ -178,11 +178,23 @@ describe(`EsQueryParser.injectQueryContextVars`, () => {
|
|||
);
|
||||
test(
|
||||
`%autointerval% = true`,
|
||||
check({ interval: { '%autointerval%': true } }, { calendar_interval: `1h` }, ctxObj)
|
||||
check(
|
||||
{ date_histogram: { interval: { '%autointerval%': true } } },
|
||||
{ date_histogram: { calendar_interval: `1h` } },
|
||||
ctxObj
|
||||
)
|
||||
);
|
||||
test(
|
||||
`%autointerval% = 10`,
|
||||
check({ interval: { '%autointerval%': 10 } }, { fixed_interval: `3h` }, ctxObj)
|
||||
check(
|
||||
{ date_histogram: { interval: { '%autointerval%': 10 } } },
|
||||
{ date_histogram: { fixed_interval: `3h` } },
|
||||
ctxObj
|
||||
)
|
||||
);
|
||||
test(
|
||||
`histogram with interval`,
|
||||
check({ histogram: { interval: 1 } }, { histogram: { interval: 1 } }, ctxObj)
|
||||
);
|
||||
test(`%timefilter% = min`, check({ a: { '%timefilter%': 'min' } }, { a: rangeStart }));
|
||||
test(`%timefilter% = max`, check({ a: { '%timefilter%': 'max' } }, { a: rangeEnd }));
|
||||
|
|
|
@ -235,7 +235,8 @@ export class EsQueryParser {
|
|||
interval?: { '%autointerval%': true | number } | string;
|
||||
}
|
||||
>,
|
||||
isQuery: boolean
|
||||
isQuery: boolean,
|
||||
key?: string
|
||||
) {
|
||||
if (obj && typeof obj === 'object') {
|
||||
if (Array.isArray(obj)) {
|
||||
|
@ -281,9 +282,8 @@ export class EsQueryParser {
|
|||
if (!subObj || typeof obj !== 'object') continue;
|
||||
|
||||
// replace "interval" with ES acceptable fixed_interval / calendar_interval
|
||||
if (prop === 'interval') {
|
||||
if (prop === 'interval' && key === 'date_histogram') {
|
||||
let intervalString: string;
|
||||
|
||||
if (typeof subObj === 'string') {
|
||||
intervalString = subObj;
|
||||
} else if (subObj[AUTOINTERVAL]) {
|
||||
|
@ -322,7 +322,7 @@ export class EsQueryParser {
|
|||
this._createRangeFilter(subObj);
|
||||
continue;
|
||||
case undefined:
|
||||
this._injectContextVars(subObj, isQuery);
|
||||
this._injectContextVars(subObj, isQuery, prop);
|
||||
continue;
|
||||
default:
|
||||
throw new Error(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue