diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e108c52..a79908f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added +- Added support for the `multi_terms` bucket aggregation ([#797](https://github.com/opensearch-project/opensearch-py/pull/797)) ### Changed - Removed deprecated `numpy.float_` and update NumPy/Pandas imports ([#762](https://github.com/opensearch-project/opensearch-py/pull/762)) - Removed workaround for [aiohttp#1769](https://github.com/aio-libs/aiohttp/issues/1769) ([#794](https://github.com/opensearch-project/opensearch-py/pull/794)) diff --git a/opensearchpy/helpers/aggs.py b/opensearchpy/helpers/aggs.py index 0133287f..b3be3614 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")