From f003c44edd5d4f96abfb7ae40760ec86175abc0c Mon Sep 17 00:00:00 2001 From: mckirk Date: Mon, 29 Jan 2024 17:58:37 +0100 Subject: [PATCH 1/4] Add MultiTerms bucket aggregation Signed-off-by: mckirk --- opensearchpy/helpers/aggs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opensearchpy/helpers/aggs.py b/opensearchpy/helpers/aggs.py index a9b87521..2a4fae48 100644 --- a/opensearchpy/helpers/aggs.py +++ b/opensearchpy/helpers/aggs.py @@ -308,6 +308,10 @@ def result(self, search: Any, data: Any) -> Any: return FieldBucketData(self, search, data) +class MultiTerms(Bucket): + name = "multi_terms" + + # metric aggregations class TopHits(Agg): name = "top_hits" From 5239532711bc20252d4bf46970e7a2ccd4db1c4a Mon Sep 17 00:00:00 2001 From: mckirk Date: Mon, 29 Jan 2024 18:01:06 +0100 Subject: [PATCH 2/4] Add test for MultiTerms bucket aggregation Signed-off-by: mckirk --- test_opensearchpy/test_helpers/test_aggs.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test_opensearchpy/test_helpers/test_aggs.py b/test_opensearchpy/test_helpers/test_aggs.py index 006edbe4..467c64a3 100644 --- a/test_opensearchpy/test_helpers/test_aggs.py +++ b/test_opensearchpy/test_helpers/test_aggs.py @@ -309,6 +309,18 @@ def test_variable_width_histogram_aggregation() -> None: assert {"variable_width_histogram": {"buckets": 2, "field": "price"}} == a.to_dict() +def test_multi_terms_aggregation() -> None: + a = aggs.MultiTerms(terms=[{"field": "tags"}, {"field": "author.row"}]) + assert { + "multi_terms": { + "terms": [ + {"field": "tags"}, + {"field": "author.row"}, + ] + } + } == a.to_dict() + + def test_median_absolute_deviation_aggregation() -> None: a = aggs.MedianAbsoluteDeviation(field="rating") From 9579afe1cc42475ab80929d83fd605c12a2a0c2b Mon Sep 17 00:00:00 2001 From: mckirk Date: Mon, 29 Jan 2024 18:14:50 +0100 Subject: [PATCH 3/4] Update CHANGELOG.md Signed-off-by: mckirk --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4ce00af..8d60ab1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added a log collection guide ([#579](https://github.com/opensearch-project/opensearch-py/pull/579)) - Added GHA release ([#614](https://github.com/opensearch-project/opensearch-py/pull/614)) - Incorporated API generation into CI workflow and fixed 'generate' nox session ([#660](https://github.com/opensearch-project/opensearch-py/pull/660)) +- Added support for the `multi_terms` bucket aggregation ### Changed - Updated the `get_policy` API in the index_management plugin to allow the policy_id argument as optional ([#633](https://github.com/opensearch-project/opensearch-py/pull/633)) - Updated the `point_in_time.md` guide with examples demonstrating the usage of the new APIs as alternatives to the deprecated ones. ([#661](https://github.com/opensearch-project/opensearch-py/pull/661)) @@ -218,4 +219,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) [2.2.0]: https://github.com/opensearch-project/opensearch-py/compare/v2.1.1...v2.2.0 [2.1.1]: https://github.com/opensearch-project/opensearch-py/compare/v2.1.0...v2.1.1 [2.1.0]: https://github.com/opensearch-project/opensearch-py/compare/v2.0.1...v2.1.0 -[2.0.1]: https://github.com/opensearch-project/opensearch-py/compare/v2.0.0...v2.0.1 \ No newline at end of file +[2.0.1]: https://github.com/opensearch-project/opensearch-py/compare/v2.0.0...v2.0.1 From 22a970cee3bf99c1c0bad4d72628b51cdbb88ac4 Mon Sep 17 00:00:00 2001 From: mckirk Date: Thu, 1 Feb 2024 17:05:24 +0100 Subject: [PATCH 4/4] Update CHANGELOG.md Signed-off-by: mckirk --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d60ab1b..4c7a50f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added a log collection guide ([#579](https://github.com/opensearch-project/opensearch-py/pull/579)) - Added GHA release ([#614](https://github.com/opensearch-project/opensearch-py/pull/614)) - Incorporated API generation into CI workflow and fixed 'generate' nox session ([#660](https://github.com/opensearch-project/opensearch-py/pull/660)) -- Added support for the `multi_terms` bucket aggregation +- Added support for the `multi_terms` bucket aggregation ([#663](https://github.com/opensearch-project/opensearch-py/pull/663)) ### Changed - Updated the `get_policy` API in the index_management plugin to allow the policy_id argument as optional ([#633](https://github.com/opensearch-project/opensearch-py/pull/633)) - Updated the `point_in_time.md` guide with examples demonstrating the usage of the new APIs as alternatives to the deprecated ones. ([#661](https://github.com/opensearch-project/opensearch-py/pull/661))