From 74c5f7b9a5aa0be369d57ab6f530cf1f3b060e69 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:44:07 +0100 Subject: [PATCH] Add MatrixStats aggregation (#1631) (#1798) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 35646106563a1bbd58cedc5d8a3b73363c8760b7) Co-authored-by: Hüseyin Emre Armağan --- elasticsearch_dsl/aggs.py | 4 ++++ tests/test_aggs.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/elasticsearch_dsl/aggs.py b/elasticsearch_dsl/aggs.py index 8f91333aa..61a27f3c4 100644 --- a/elasticsearch_dsl/aggs.py +++ b/elasticsearch_dsl/aggs.py @@ -333,6 +333,10 @@ class Max(Agg): name = "max" +class MatrixStats(Agg): + name = "matrix_stats" + + class MedianAbsoluteDeviation(Agg): name = "median_absolute_deviation" diff --git a/tests/test_aggs.py b/tests/test_aggs.py index 0874a66c4..327892862 100644 --- a/tests/test_aggs.py +++ b/tests/test_aggs.py @@ -341,6 +341,12 @@ def test_inference_aggregation(): } == a.to_dict() +def test_matrix_stats_aggregation(): + a = aggs.MatrixStats(fields=["poverty", "income"]) + + assert {"matrix_stats": {"fields": ["poverty", "income"]}} == a.to_dict() + + def test_moving_percentiles_aggregation(): a = aggs.DateHistogram() a.bucket("the_percentile", "percentiles", field="price", percents=[1.0, 99.0])