File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,10 @@ class IPRange(Bucket):
232
232
name = "ip_range"
233
233
234
234
235
+ class IPPrefix (Bucket ):
236
+ name = "ip_prefix"
237
+
238
+
235
239
class Missing (Bucket ):
236
240
name = "missing"
237
241
Original file line number Diff line number Diff line change @@ -300,6 +300,30 @@ def test_variable_width_histogram_aggregation():
300
300
assert {"variable_width_histogram" : {"buckets" : 2 , "field" : "price" }} == a .to_dict ()
301
301
302
302
303
+ def test_ip_prefix_aggregation ():
304
+ a = aggs .IPPrefix (** {"field" : "ipv4" , "prefix_length" : 24 })
305
+
306
+ assert {"ip_prefix" : {"field" : "ipv4" , "prefix_length" : 24 }} == a .to_dict ()
307
+
308
+
309
+ def test_ip_prefix_aggregation_extra ():
310
+ a = aggs .IPPrefix (
311
+ ** {
312
+ "field" : "ipv6" ,
313
+ "prefix_length" : 64 ,
314
+ "is_ipv6" : True ,
315
+ }
316
+ )
317
+
318
+ assert {
319
+ "ip_prefix" : {
320
+ "field" : "ipv6" ,
321
+ "prefix_length" : 64 ,
322
+ "is_ipv6" : True ,
323
+ },
324
+ } == a .to_dict ()
325
+
326
+
303
327
def test_multi_terms_aggregation ():
304
328
a = aggs .MultiTerms (terms = [{"field" : "tags" }, {"field" : "author.row" }])
305
329
assert {
You can’t perform that action at this time.
0 commit comments