Skip to content

Commit

Permalink
Added support for the bucket aggregation.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
mckirk authored and dblock committed Aug 15, 2024
1 parent be56ae8 commit fe930be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 4 additions & 0 deletions opensearchpy/helpers/aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions test_opensearchpy/test_helpers/test_aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit fe930be

Please sign in to comment.