Skip to content
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

Add support for adjacency matrix #1554

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions elasticsearch_dsl/aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ class Parent(Bucket):
name = "parent"


class AdjacencyMatrix(Bucket):
name = "adjacency_matrix"


class DateHistogram(Bucket):
name = "date_histogram"

Expand Down
19 changes: 19 additions & 0 deletions tests/test_aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down