[ML] Fixing "aggs" use in datafeeds (#56002) (#56017)

* [ML] Fixing "aggs" use in datafeeds

* removing use of Record
This commit is contained in:
James Gowdy 2020-01-27 16:42:59 +00:00 committed by GitHub
parent dc7eba0351
commit 94a40fbb3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View file

@ -11,6 +11,7 @@ export type DatafeedId = string;
export interface Datafeed {
datafeed_id: DatafeedId;
aggregations?: Aggregation;
aggs?: Aggregation;
chunking_config?: ChunkingConfig;
frequency?: string;
indices: IndexPatternTitle[];
@ -33,6 +34,7 @@ interface Aggregation {
field: string;
fixed_interval: string;
};
aggregations: Record<string, any>;
aggregations?: { [key: string]: any };
aggs?: { [key: string]: any };
};
}

View file

@ -623,8 +623,10 @@ export class JobCreator {
}
this._aggregationFields = [];
if (this._datafeed_config.aggregations?.buckets !== undefined) {
collectAggs(this._datafeed_config.aggregations.buckets, this._aggregationFields);
const buckets =
this._datafeed_config.aggregations?.buckets || this._datafeed_config.aggs?.buckets;
if (buckets !== undefined) {
collectAggs(buckets, this._aggregationFields);
}
}
}

View file

@ -325,7 +325,7 @@ export function collectAggs(o: any, aggFields: Field[]) {
if (o[i] !== null && typeof o[i] === 'object') {
if (i === 'aggregations' || i === 'aggs') {
Object.keys(o[i]).forEach(k => {
if (k !== 'aggregations' && i !== 'aggs') {
if (k !== 'aggregations' && k !== 'aggs') {
aggFields.push({
id: k,
name: k,