Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CompositeAggregation#missingBucket #108

Merged
merged 4 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ class ValuesSourceBase {
* Missing specifies the value to use when the source finds a missing value
* in a document.
*
* Note: The `missing` option of the composite aggregation is deprecated in
* [Elasticsearch v6.0](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/breaking-changes-6.0.html#_literal_missing_literal_is_deprecated_in_the_literal_composite_literal_aggregation),
* `missing_bucket` should be used instead.
*
* @param {string} value
* @returns {ValuesSourceBase} returns `this` so that calls can be chained
*/
Expand All @@ -105,6 +109,21 @@ class ValuesSourceBase {
return this;
}

/**
* Specifies whether to include documents without a value for a given source
* in the response. Defaults to `false` (not included).
*
* Note: This method is incompatible with elasticsearch 5.6 and older.
* Use it only with elasticsearch 6.0 and later.
*
* @param {boolean} value
* @returns {ValuesSourceBase} returns `this` so that calls can be chained
*/
missingBucket(value) {
this._opts.missing_bucket = value;
return this;
}

/**
* Override default `toJSON` to return DSL representation for the Composite
* Aggregation values source.
Expand Down
15 changes: 15 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4655,10 +4655,25 @@ declare namespace esb {
* Missing specifies the value to use when the source finds a missing value
* in a document.
*
* Note: The `missing` option of the composite aggregation is deprecated in
* [Elasticsearch v6.0](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/breaking-changes-6.0.html#_literal_missing_literal_is_deprecated_in_the_literal_composite_literal_aggregation),
* `missing_bucket` should be used instead.
*
* @param {string} value
*/
missing(value: string): this;

/**
* Specifies to include documents without a value for a given source in the
* response, or not. Defaults to `false` (not include).
*
* Note: This method is incompatible with elasticsearch 5.6 and older.
* Use it only with elasticsearch 6.0 and later.
*
* @param {boolean} value
*/
missingBucket(value: boolean): this;

/**
* Override default `toJSON` to return DSL representation for the Composite
* Aggregation values source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test('constructor sets arguments', t => {
test(setsAggType, TermsValuesSource, 'terms');
test(validatedCorrectly, getInstance, 'order', ['asc', 'desc']);
test(setsOption, 'missing', { param: 42 });
test(setsOption, 'missingBucket', { param: 42 });
test(setsOption, 'field', { param: 'my_field' });
test(setsOption, 'script', {
param: new Script()
Expand Down