Skip to content

Commit

Permalink
Add IPPrefix aggregation (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
Telomeraz committed Apr 15, 2024
1 parent 380b63b commit f091a23
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions elasticsearch_dsl/aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ class IPRange(Bucket):
name = "ip_range"


class IPPrefix(Bucket):
name = "ip_prefix"


class Missing(Bucket):
name = "missing"

Expand Down
24 changes: 24 additions & 0 deletions tests/test_aggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,30 @@ def test_variable_width_histogram_aggregation():
assert {"variable_width_histogram": {"buckets": 2, "field": "price"}} == a.to_dict()


def test_ip_prefix_aggregation():
a = aggs.IPPrefix(**{"field": "ipv4", "prefix_length": 24})

assert {"ip_prefix": {"field": "ipv4", "prefix_length": 24}} == a.to_dict()


def test_ip_prefix_aggregation_extra():
a = aggs.IPPrefix(
**{
"field": "ipv6",
"prefix_length": 64,
"is_ipv6": True,
}
)

assert {
"ip_prefix": {
"field": "ipv6",
"prefix_length": 64,
"is_ipv6": True,
},
} == a.to_dict()


def test_multi_terms_aggregation():
a = aggs.MultiTerms(terms=[{"field": "tags"}, {"field": "author.row"}])
assert {
Expand Down

0 comments on commit f091a23

Please sign in to comment.