diff --git a/CHANGELOG.md b/CHANGELOG.md index f4ce00af..4c7a50f4 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 ([#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)) @@ -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 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" 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")