Skip to content

Commit

Permalink
feat(Aggs): Described all aggregation inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Mar 17, 2017
1 parent 9d2adf8 commit 380c73a
Show file tree
Hide file tree
Showing 16 changed files with 1,351 additions and 5 deletions.
28 changes: 28 additions & 0 deletions src/ElasticDSL/Aggs/AggRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ import { getSamplerITC } from './Bucket/Sampler';
import { getSignificantTermsITC } from './Bucket/SignificantTerms';
import { getTermsITC } from './Bucket/Terms';

import { getAvgBucketITC } from './Pipeline/AvgBucket';
import { getBucketScriptITC } from './Pipeline/BucketScript';
import { getBucketSelectorITC } from './Pipeline/BucketSelector';
import { getCumulativeSumITC } from './Pipeline/CumulativeSum';
import { getDerivativeITC } from './Pipeline/Derivative';
import { getExtendedStatsBucketITC } from './Pipeline/ExtendedStatsBucket';
import { getMaxBucketITC } from './Pipeline/MaxBucket';
import { getMinBucketITC } from './Pipeline/MinBucket';
import { getMovingAverageITC } from './Pipeline/MovingAverage';
import { getPercentilesBucketITC } from './Pipeline/PercentilesBucket';
import { getSerialDifferencingITC } from './Pipeline/SerialDifferencing';
import { getStatsBucketITC } from './Pipeline/StatsBucket';
import { getSumBucketITC } from './Pipeline/SumBucket';

export function getAggRulesITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggRules', opts);
const description = desc(
Expand Down Expand Up @@ -89,6 +103,20 @@ export function getAggRulesITC(opts: mixed = {}): InputTypeComposer {
significant_terms: () => getSignificantTermsITC(opts),
terms: () => getTermsITC(opts),

avg_bucket: () => getAvgBucketITC(opts),
bucket_script: () => getBucketScriptITC(opts),
bucket_selector: () => getBucketSelectorITC(opts),
cumulative_sum: () => getCumulativeSumITC(opts),
derivative: () => getDerivativeITC(opts),
extended_stats_bucket: () => getExtendedStatsBucketITC(opts),
max_bucket: () => getMaxBucketITC(opts),
min_bucket: () => getMinBucketITC(opts),
moving_average: () => getMovingAverageITC(opts),
percentiles_bucket: () => getPercentilesBucketITC(opts),
serial_differencing: () => getSerialDifferencingITC(opts),
stats_bucket: () => getStatsBucketITC(opts),
sum_bucket: () => getSumBucketITC(opts),

aggs: {
type: () => [getAggBlockITC(opts)],
description: 'Aggregation block',
Expand Down
28 changes: 28 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/AvgBucket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getAvgBucketITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsAvgBucket', opts);
const description = desc(
`
A sibling pipeline aggregation which calculates the (mean) average value
of a specified metric in a sibling aggregation. The specified metric must
be numeric and the sibling aggregation must be a multi-bucket aggregation.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
gap_policy: 'String',
format: 'String',
},
}));
}
30 changes: 30 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/BucketScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getBucketScriptITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsBucketScript', opts);
const description = desc(
`
A parent pipeline aggregation which executes a script which can perform
per bucket computations on specified metrics in the parent multi-bucket
aggregation. The specified metric must be numeric and the script must
return a numeric value.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'JSON!',
script: 'String!',
format: 'String',
gap_policy: 'String',
},
}));
}
31 changes: 31 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/BucketSelector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getBucketSelectorITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsBucketSelector', opts);
const description = desc(
`
A parent pipeline aggregation which executes a script which determines
whether the current bucket will be retained in the parent multi-bucket
aggregation. The specified metric must be numeric and the script must
return a boolean value. If the script language is expression then a numeric
return value is permitted. In this case 0.0 will be evaluated as false
and all other values will evaluate to true.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'JSON!',
script: 'String!',
gap_policy: 'String',
},
}));
}
28 changes: 28 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/CumulativeSum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getCumulativeSumITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsCumulativeSum', opts);
const description = desc(
`
A parent pipeline aggregation which calculates the cumulative sum of a
specified metric in a parent histogram (or date_histogram) aggregation.
The specified metric must be numeric and the enclosing histogram must
have min_doc_count set to 0 (default for histogram aggregations).
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-cumulative-sum-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
format: 'String',
},
}));
}
30 changes: 30 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/Derivative.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getDerivativeITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsDerivative', opts);
const description = desc(
`
A parent pipeline aggregation which calculates the derivative of a specified
metric in a parent histogram (or date_histogram) aggregation. The specified
metric must be numeric and the enclosing histogram must have min_doc_count
set to 0 (default for histogram aggregations).
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-derivative-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
gap_policy: 'String',
format: 'String',
unit: 'String',
},
}));
}
30 changes: 30 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/ExtendedStatsBucket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getExtendedStatsBucketITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsExtendedStatsBucket', opts);
const description = desc(
`
A sibling pipeline aggregation which calculates a variety of stats across
all bucket of a specified metric in a sibling aggregation. The specified
metric must be numeric and the sibling aggregation must be a multi-bucket
aggregation.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-extended-stats-bucket-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
gap_policy: 'String',
format: 'String',
sigma: 'Float',
},
}));
}
30 changes: 30 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/MaxBucket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getMaxBucketITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsMaxBucket', opts);
const description = desc(
`
A sibling pipeline aggregation which identifies the bucket(s) with
the maximum value of a specified metric in a sibling aggregation and
outputs both the value and the key(s) of the bucket(s). The specified
metric must be numeric and the sibling aggregation must be a multi-bucket
aggregation.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-max-bucket-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
gap_policy: 'String',
format: 'String',
},
}));
}
30 changes: 30 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/MinBucket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getMinBucketITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsMinBucket', opts);
const description = desc(
`
A sibling pipeline aggregation which identifies the bucket(s) with
the minimum value of a specified metric in a sibling aggregation and
outputs both the value and the key(s) of the bucket(s). The specified
metric must be numeric and the sibling aggregation must be a multi-bucket
aggregation.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-min-bucket-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
gap_policy: 'String',
format: 'String',
},
}));
}
30 changes: 30 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/MovingAverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getMovingAverageITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsMovingAverage', opts);
const description = desc(
`
Given an ordered series of data, the Moving Average aggregation will slide
a window across the data and emit the average value of that window.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-movavg-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
format: 'String',
window: 'Int',
gap_policy: 'String',
model: 'String',
settings: 'JSON',
},
}));
}
29 changes: 29 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/PercentilesBucket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getPercentilesBucketITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsPercentilesBucket', opts);
const description = desc(
`
A sibling pipeline aggregation which calculates percentiles across all
bucket of a specified metric in a sibling aggregation. The specified metric
must be numeric and the sibling aggregation must be a multi-bucket aggregation.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-percentiles-bucket-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
gap_policy: 'String',
format: 'String',
percents: '[Float]',
},
}));
}
28 changes: 28 additions & 0 deletions src/ElasticDSL/Aggs/Pipeline/SerialDifferencing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* @flow */

import { InputTypeComposer } from 'graphql-compose';
import { getTypeName, getOrSetType, desc } from '../../../utils';

export function getSerialDifferencingITC(opts: mixed = {}): InputTypeComposer {
const name = getTypeName('AggsSerialDifferencing', opts);
const description = desc(
`
Serial differencing is a technique where values in a time series are
subtracted from itself at different time lags or periods.
[Documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html)
`
);

return getOrSetType(name, () =>
// $FlowFixMe
InputTypeComposer.create({
name,
description,
fields: {
buckets_path: 'String!',
lag: 'String',
gap_policy: 'String',
format: 'String',
},
}));
}
Loading

0 comments on commit 380c73a

Please sign in to comment.