Skip to content

Commit 380c73a

Browse files
committed
feat(Aggs): Described all aggregation inputs
1 parent 9d2adf8 commit 380c73a

16 files changed

+1351
-5
lines changed

src/ElasticDSL/Aggs/AggRules.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ import { getSamplerITC } from './Bucket/Sampler';
3838
import { getSignificantTermsITC } from './Bucket/SignificantTerms';
3939
import { getTermsITC } from './Bucket/Terms';
4040

41+
import { getAvgBucketITC } from './Pipeline/AvgBucket';
42+
import { getBucketScriptITC } from './Pipeline/BucketScript';
43+
import { getBucketSelectorITC } from './Pipeline/BucketSelector';
44+
import { getCumulativeSumITC } from './Pipeline/CumulativeSum';
45+
import { getDerivativeITC } from './Pipeline/Derivative';
46+
import { getExtendedStatsBucketITC } from './Pipeline/ExtendedStatsBucket';
47+
import { getMaxBucketITC } from './Pipeline/MaxBucket';
48+
import { getMinBucketITC } from './Pipeline/MinBucket';
49+
import { getMovingAverageITC } from './Pipeline/MovingAverage';
50+
import { getPercentilesBucketITC } from './Pipeline/PercentilesBucket';
51+
import { getSerialDifferencingITC } from './Pipeline/SerialDifferencing';
52+
import { getStatsBucketITC } from './Pipeline/StatsBucket';
53+
import { getSumBucketITC } from './Pipeline/SumBucket';
54+
4155
export function getAggRulesITC(opts: mixed = {}): InputTypeComposer {
4256
const name = getTypeName('AggRules', opts);
4357
const description = desc(
@@ -89,6 +103,20 @@ export function getAggRulesITC(opts: mixed = {}): InputTypeComposer {
89103
significant_terms: () => getSignificantTermsITC(opts),
90104
terms: () => getTermsITC(opts),
91105

106+
avg_bucket: () => getAvgBucketITC(opts),
107+
bucket_script: () => getBucketScriptITC(opts),
108+
bucket_selector: () => getBucketSelectorITC(opts),
109+
cumulative_sum: () => getCumulativeSumITC(opts),
110+
derivative: () => getDerivativeITC(opts),
111+
extended_stats_bucket: () => getExtendedStatsBucketITC(opts),
112+
max_bucket: () => getMaxBucketITC(opts),
113+
min_bucket: () => getMinBucketITC(opts),
114+
moving_average: () => getMovingAverageITC(opts),
115+
percentiles_bucket: () => getPercentilesBucketITC(opts),
116+
serial_differencing: () => getSerialDifferencingITC(opts),
117+
stats_bucket: () => getStatsBucketITC(opts),
118+
sum_bucket: () => getSumBucketITC(opts),
119+
92120
aggs: {
93121
type: () => [getAggBlockITC(opts)],
94122
description: 'Aggregation block',
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getAvgBucketITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsAvgBucket', opts);
8+
const description = desc(
9+
`
10+
A sibling pipeline aggregation which calculates the (mean) average value
11+
of a specified metric in a sibling aggregation. The specified metric must
12+
be numeric and the sibling aggregation must be a multi-bucket aggregation.
13+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html)
14+
`
15+
);
16+
17+
return getOrSetType(name, () =>
18+
// $FlowFixMe
19+
InputTypeComposer.create({
20+
name,
21+
description,
22+
fields: {
23+
buckets_path: 'String!',
24+
gap_policy: 'String',
25+
format: 'String',
26+
},
27+
}));
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getBucketScriptITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsBucketScript', opts);
8+
const description = desc(
9+
`
10+
A parent pipeline aggregation which executes a script which can perform
11+
per bucket computations on specified metrics in the parent multi-bucket
12+
aggregation. The specified metric must be numeric and the script must
13+
return a numeric value.
14+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html)
15+
`
16+
);
17+
18+
return getOrSetType(name, () =>
19+
// $FlowFixMe
20+
InputTypeComposer.create({
21+
name,
22+
description,
23+
fields: {
24+
buckets_path: 'JSON!',
25+
script: 'String!',
26+
format: 'String',
27+
gap_policy: 'String',
28+
},
29+
}));
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getBucketSelectorITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsBucketSelector', opts);
8+
const description = desc(
9+
`
10+
A parent pipeline aggregation which executes a script which determines
11+
whether the current bucket will be retained in the parent multi-bucket
12+
aggregation. The specified metric must be numeric and the script must
13+
return a boolean value. If the script language is expression then a numeric
14+
return value is permitted. In this case 0.0 will be evaluated as false
15+
and all other values will evaluate to true.
16+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html)
17+
`
18+
);
19+
20+
return getOrSetType(name, () =>
21+
// $FlowFixMe
22+
InputTypeComposer.create({
23+
name,
24+
description,
25+
fields: {
26+
buckets_path: 'JSON!',
27+
script: 'String!',
28+
gap_policy: 'String',
29+
},
30+
}));
31+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getCumulativeSumITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsCumulativeSum', opts);
8+
const description = desc(
9+
`
10+
A parent pipeline aggregation which calculates the cumulative sum of a
11+
specified metric in a parent histogram (or date_histogram) aggregation.
12+
The specified metric must be numeric and the enclosing histogram must
13+
have min_doc_count set to 0 (default for histogram aggregations).
14+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-cumulative-sum-aggregation.html)
15+
`
16+
);
17+
18+
return getOrSetType(name, () =>
19+
// $FlowFixMe
20+
InputTypeComposer.create({
21+
name,
22+
description,
23+
fields: {
24+
buckets_path: 'String!',
25+
format: 'String',
26+
},
27+
}));
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getDerivativeITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsDerivative', opts);
8+
const description = desc(
9+
`
10+
A parent pipeline aggregation which calculates the derivative of a specified
11+
metric in a parent histogram (or date_histogram) aggregation. The specified
12+
metric must be numeric and the enclosing histogram must have min_doc_count
13+
set to 0 (default for histogram aggregations).
14+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-derivative-aggregation.html)
15+
`
16+
);
17+
18+
return getOrSetType(name, () =>
19+
// $FlowFixMe
20+
InputTypeComposer.create({
21+
name,
22+
description,
23+
fields: {
24+
buckets_path: 'String!',
25+
gap_policy: 'String',
26+
format: 'String',
27+
unit: 'String',
28+
},
29+
}));
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getExtendedStatsBucketITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsExtendedStatsBucket', opts);
8+
const description = desc(
9+
`
10+
A sibling pipeline aggregation which calculates a variety of stats across
11+
all bucket of a specified metric in a sibling aggregation. The specified
12+
metric must be numeric and the sibling aggregation must be a multi-bucket
13+
aggregation.
14+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-extended-stats-bucket-aggregation.html)
15+
`
16+
);
17+
18+
return getOrSetType(name, () =>
19+
// $FlowFixMe
20+
InputTypeComposer.create({
21+
name,
22+
description,
23+
fields: {
24+
buckets_path: 'String!',
25+
gap_policy: 'String',
26+
format: 'String',
27+
sigma: 'Float',
28+
},
29+
}));
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getMaxBucketITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsMaxBucket', opts);
8+
const description = desc(
9+
`
10+
A sibling pipeline aggregation which identifies the bucket(s) with
11+
the maximum value of a specified metric in a sibling aggregation and
12+
outputs both the value and the key(s) of the bucket(s). The specified
13+
metric must be numeric and the sibling aggregation must be a multi-bucket
14+
aggregation.
15+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-max-bucket-aggregation.html)
16+
`
17+
);
18+
19+
return getOrSetType(name, () =>
20+
// $FlowFixMe
21+
InputTypeComposer.create({
22+
name,
23+
description,
24+
fields: {
25+
buckets_path: 'String!',
26+
gap_policy: 'String',
27+
format: 'String',
28+
},
29+
}));
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getMinBucketITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsMinBucket', opts);
8+
const description = desc(
9+
`
10+
A sibling pipeline aggregation which identifies the bucket(s) with
11+
the minimum value of a specified metric in a sibling aggregation and
12+
outputs both the value and the key(s) of the bucket(s). The specified
13+
metric must be numeric and the sibling aggregation must be a multi-bucket
14+
aggregation.
15+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-min-bucket-aggregation.html)
16+
`
17+
);
18+
19+
return getOrSetType(name, () =>
20+
// $FlowFixMe
21+
InputTypeComposer.create({
22+
name,
23+
description,
24+
fields: {
25+
buckets_path: 'String!',
26+
gap_policy: 'String',
27+
format: 'String',
28+
},
29+
}));
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getMovingAverageITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsMovingAverage', opts);
8+
const description = desc(
9+
`
10+
Given an ordered series of data, the Moving Average aggregation will slide
11+
a window across the data and emit the average value of that window.
12+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-movavg-aggregation.html)
13+
`
14+
);
15+
16+
return getOrSetType(name, () =>
17+
// $FlowFixMe
18+
InputTypeComposer.create({
19+
name,
20+
description,
21+
fields: {
22+
buckets_path: 'String!',
23+
format: 'String',
24+
window: 'Int',
25+
gap_policy: 'String',
26+
model: 'String',
27+
settings: 'JSON',
28+
},
29+
}));
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getPercentilesBucketITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsPercentilesBucket', opts);
8+
const description = desc(
9+
`
10+
A sibling pipeline aggregation which calculates percentiles across all
11+
bucket of a specified metric in a sibling aggregation. The specified metric
12+
must be numeric and the sibling aggregation must be a multi-bucket aggregation.
13+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-percentiles-bucket-aggregation.html)
14+
`
15+
);
16+
17+
return getOrSetType(name, () =>
18+
// $FlowFixMe
19+
InputTypeComposer.create({
20+
name,
21+
description,
22+
fields: {
23+
buckets_path: 'String!',
24+
gap_policy: 'String',
25+
format: 'String',
26+
percents: '[Float]',
27+
},
28+
}));
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* @flow */
2+
3+
import { InputTypeComposer } from 'graphql-compose';
4+
import { getTypeName, getOrSetType, desc } from '../../../utils';
5+
6+
export function getSerialDifferencingITC(opts: mixed = {}): InputTypeComposer {
7+
const name = getTypeName('AggsSerialDifferencing', opts);
8+
const description = desc(
9+
`
10+
Serial differencing is a technique where values in a time series are
11+
subtracted from itself at different time lags or periods.
12+
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html)
13+
`
14+
);
15+
16+
return getOrSetType(name, () =>
17+
// $FlowFixMe
18+
InputTypeComposer.create({
19+
name,
20+
description,
21+
fields: {
22+
buckets_path: 'String!',
23+
lag: 'String',
24+
gap_policy: 'String',
25+
format: 'String',
26+
},
27+
}));
28+
}

0 commit comments

Comments
 (0)