Adding range filter to ownerId aggregation (#113557)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
ymao1 2021-10-04 10:06:07 -04:00 committed by GitHub
parent 1ff02e1da6
commit 8c89daedba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 9 deletions

View file

@ -65,7 +65,9 @@ describe('Workload Statistics Aggregator', () => {
doc_count: 13,
},
ownerIds: {
value: 1,
ownerIds: {
value: 1,
},
},
// The `FiltersAggregate` doesn't cover the case of a nested `AggregationsAggregationContainer`, in which `FiltersAggregate`
// would not have a `buckets` property, but rather a keyed property that's inferred from the request.
@ -127,8 +129,19 @@ describe('Workload Statistics Aggregator', () => {
missing: { field: 'task.schedule' },
},
ownerIds: {
cardinality: {
field: 'task.ownerId',
filter: {
range: {
'task.startedAt': {
gte: 'now-1w/w',
},
},
},
aggs: {
ownerIds: {
cardinality: {
field: 'task.ownerId',
},
},
},
},
idleTasks: {
@ -264,7 +277,9 @@ describe('Workload Statistics Aggregator', () => {
doc_count: 13,
},
ownerIds: {
value: 1,
ownerIds: {
value: 1,
},
},
// The `FiltersAggregate` doesn't cover the case of a nested `AggregationsAggregationContainer`, in which `FiltersAggregate`
// would not have a `buckets` property, but rather a keyed property that's inferred from the request.
@ -605,7 +620,9 @@ describe('Workload Statistics Aggregator', () => {
doc_count: 13,
},
ownerIds: {
value: 3,
ownerIds: {
value: 3,
},
},
// The `FiltersAggregate` doesn't cover the case of a nested `AggregationContainer`, in which `FiltersAggregate`
// would not have a `buckets` property, but rather a keyed property that's inferred from the request.

View file

@ -147,8 +147,19 @@ export function createWorkloadAggregator(
missing: { field: 'task.schedule' },
},
ownerIds: {
cardinality: {
field: 'task.ownerId',
filter: {
range: {
'task.startedAt': {
gte: 'now-1w/w',
},
},
},
aggs: {
ownerIds: {
cardinality: {
field: 'task.ownerId',
},
},
},
},
idleTasks: {
@ -213,7 +224,7 @@ export function createWorkloadAggregator(
const taskTypes = aggregations.taskType.buckets;
const nonRecurring = aggregations.nonRecurringTasks.doc_count;
const ownerIds = aggregations.ownerIds.value;
const ownerIds = aggregations.ownerIds.ownerIds.value;
const {
overdue: {
@ -448,7 +459,9 @@ export interface WorkloadAggregationResponse {
doc_count: number;
};
ownerIds: {
value: number;
ownerIds: {
value: number;
};
};
[otherAggs: string]: estypes.AggregationsAggregate;
}