Skip to content

[Backport 8.x] Added "adjacency_matrix" and "top_metrics" aggregations #1815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions elasticsearch_dsl/aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ class AutoDateHistogram(DateHistogram):
name = "auto_date_histogram"


class AdjacencyMatrix(Bucket):
name = "adjacency_matrix"


class DateRange(Bucket):
name = "date_range"

Expand Down Expand Up @@ -385,6 +389,10 @@ class Sum(Agg):
name = "sum"


class TopMetrics(Agg):
name = "top_metrics"


class TTest(Agg):
name = "t_test"

Expand Down
27 changes: 27 additions & 0 deletions tests/test_aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,30 @@ def test_random_sampler_aggregation():
},
},
} == a.to_dict()


def test_adjancecy_matrix_aggregation():
a = aggs.AdjacencyMatrix(
filters={
"grpA": {"terms": {"accounts": ["hillary", "sidney"]}},
"grpB": {"terms": {"accounts": ["donald", "mitt"]}},
"grpC": {"terms": {"accounts": ["vladimir", "nigel"]}},
}
)
assert {
"adjacency_matrix": {
"filters": {
"grpA": {"terms": {"accounts": ["hillary", "sidney"]}},
"grpB": {"terms": {"accounts": ["donald", "mitt"]}},
"grpC": {"terms": {"accounts": ["vladimir", "nigel"]}},
}
}
} == a.to_dict()


def test_top_metrics_aggregation():
a = aggs.TopMetrics(metrics={"field": "m"}, sort={"s": "desc"})

assert {
"top_metrics": {"metrics": {"field": "m"}, "sort": {"s": "desc"}}
} == a.to_dict()
Loading