From 9297b43937eaf39f0206899859c6a57d16eef3b2 Mon Sep 17 00:00:00 2001 From: exoego Date: Tue, 21 Jan 2020 16:49:28 +0900 Subject: [PATCH 1/4] Add CompositeAggregation#missingBucket https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html#_missing_bucket --- .../values-source-base.js | 11 +++++++++++ src/index.d.ts | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js b/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js index fde16925..e23e537b 100644 --- a/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js +++ b/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js @@ -105,6 +105,17 @@ class ValuesSourceBase { return this; } + /** + * Specifies to include documents without a value for a given source in the + * response,or not. Defaults to `false` (not include. + * + * @param {boolean} value + */ + missingBucket(value) { + this._opts.missing_bucket = value; + return this; + } + /** * Override default `toJSON` to return DSL representation for the Composite * Aggregation values source. diff --git a/src/index.d.ts b/src/index.d.ts index 9828b6c0..ca6c1b68 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -4655,10 +4655,22 @@ 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 + * [Elastticsearch 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). + * + * @param {boolean} value + */ + missingBucket(value: boolean): this; + /** * Override default `toJSON` to return DSL representation for the Composite * Aggregation values source. From 1ee79ebb89ea59fb432c0d531236861e506da576 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 23 Jan 2020 16:28:38 +0900 Subject: [PATCH 2/4] Correct document --- .../values-source-base.js | 12 ++++++++++-- src/index.d.ts | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js b/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js index e23e537b..7874b774 100644 --- a/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js +++ b/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js @@ -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 */ @@ -106,10 +110,14 @@ class ValuesSourceBase { } /** - * Specifies to include documents without a value for a given source in the - * response,or not. Defaults to `false` (not include. + * 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; diff --git a/src/index.d.ts b/src/index.d.ts index ca6c1b68..575eebc7 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -4656,7 +4656,7 @@ declare namespace esb { * in a document. * * Note: The `missing` option of the composite aggregation is deprecated in - * [Elastticsearch 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), + * [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 @@ -4666,7 +4666,10 @@ declare namespace esb { /** * 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; From 849225af01bf98066de0e9a1fcf2c06b72b8f6e0 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 23 Jan 2020 16:40:02 +0900 Subject: [PATCH 3/4] Add test --- .../terms-values-source.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/aggregations-test/composite-agg-values-sources-test/terms-values-source.test.js b/test/aggregations-test/composite-agg-values-sources-test/terms-values-source.test.js index ba61b96a..6e0ed381 100644 --- a/test/aggregations-test/composite-agg-values-sources-test/terms-values-source.test.js +++ b/test/aggregations-test/composite-agg-values-sources-test/terms-values-source.test.js @@ -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() From 0f24ed43f27b3a3dcf8c6c11d8f921e57cfc76c9 Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Fri, 24 Jan 2020 09:08:17 +0530 Subject: [PATCH 4/4] Minor corrections --- .../values-source-base.js | 12 +++++------ src/index.d.ts | 20 +++++++++---------- .../terms-values-source.test.js | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js b/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js index 7874b774..7cb8099a 100644 --- a/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js +++ b/src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js @@ -97,11 +97,11 @@ 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. + * Note: This option was deprecated in + * [Elasticsearch v6](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). + * From 6.4 and later, use `missing_bucket` instead. * - * @param {string} value + * @param {string|number} value * @returns {ValuesSourceBase} returns `this` so that calls can be chained */ missing(value) { @@ -113,8 +113,8 @@ class ValuesSourceBase { * 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. + * Note: This method is incompatible with elasticsearch 6.3 and older. + * Use it only with elasticsearch 6.4 and later. * * @param {boolean} value * @returns {ValuesSourceBase} returns `this` so that calls can be chained diff --git a/src/index.d.ts b/src/index.d.ts index 575eebc7..c5abf585 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -143,7 +143,7 @@ declare namespace esb { * * @param {boolean|number} enable */ - trackTotalHits(enable: boolean|number): this; + trackTotalHits(enable: boolean | number): this; /** * Allows to control how the `_source` field is returned with every hit. @@ -4655,20 +4655,20 @@ 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 + * Note: Thes option was 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). + * From 6.4 and later, use `missing_bucket` instead. + * + * @param {string|number} value */ - missing(value: string): this; + missing(value: string | number): 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. + * Note: This method is incompatible with elasticsearch 6.3 and older. + * Use it only with elasticsearch 6.4 and later. * * @param {boolean} value */ @@ -8365,7 +8365,7 @@ declare namespace esb { * @param {string} nested.path Nested object to sort on * @param {Query} nested.filter Filter query */ - nested(nested: { path: string, filter: Query }): this; + nested(nested: { path: string; filter: Query }): this; /** * The missing parameter specifies how docs which are missing the field should diff --git a/test/aggregations-test/composite-agg-values-sources-test/terms-values-source.test.js b/test/aggregations-test/composite-agg-values-sources-test/terms-values-source.test.js index 6e0ed381..d2fc8b31 100644 --- a/test/aggregations-test/composite-agg-values-sources-test/terms-values-source.test.js +++ b/test/aggregations-test/composite-agg-values-sources-test/terms-values-source.test.js @@ -36,7 +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, 'missingBucket', { param: true }); test(setsOption, 'field', { param: 'my_field' }); test(setsOption, 'script', { param: new Script()