diff --git a/elasticsearch_dsl/aggs.py b/elasticsearch_dsl/aggs.py index 3b55a8ab1..1ffcc17c7 100644 --- a/elasticsearch_dsl/aggs.py +++ b/elasticsearch_dsl/aggs.py @@ -189,6 +189,10 @@ class Parent(Bucket): name = "parent" +class AdjacencyMatrix(Bucket): + name = "adjacency_matrix" + + class DateHistogram(Bucket): name = "date_histogram" diff --git a/tests/test_aggs.py b/tests/test_aggs.py index 0874a66c4..67699758f 100644 --- a/tests/test_aggs.py +++ b/tests/test_aggs.py @@ -112,6 +112,25 @@ def test_A_fails_with_agg_and_params(): aggs.A(a, field="score") +def test_adjacency_matrix(): + filters = { + "grpA": {"terms": {"accounts": ["hillary", "sidney"]}}, + "grpB": {"terms": {"accounts": ["donald", "mitt"]}}, + "grpC": {"terms": {"accounts": ["vladimir", "nigel"]}}, + } + + a = aggs.AdjacencyMatrix(filters=filters) + assert { + "adjacency_matrix": { + "filters": { + "grpA": {"terms": {"accounts": ["hillary", "sidney"]}}, + "grpB": {"terms": {"accounts": ["donald", "mitt"]}}, + "grpC": {"terms": {"accounts": ["vladimir", "nigel"]}} + } + } + } == a.to_dict() + + def test_buckets_are_nestable(): a = aggs.Terms(field="tags") b = a.bucket("per_author", "terms", field="author.raw")