WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
IPv4 Range aggregation
editIPv4 Range aggregation
editJust like the dedicated date range aggregation, there is also a dedicated range aggregation for IPv4 typed fields.
Fluent DSL
editvar result = client.Search<ElasticsearchProject>(s => s .Aggregations(a => a .IpRange("my_iprange_agg", d => d .Field(p => p.PingIP) .Ranges("10.0.0.0/25", "10.0.0.127/25") ) ) ); var agg = result.Aggs.IpRange("my_iprange_agg");
Object Initializer Syntax
editvar request = new SearchRequest { Aggregations = new Dictionary<string, IAggregationContainer> { { "my_iprange_agg", new AggregationContainer { IpRange = new Ip4RangeAggregator { Field = "pingIp", Ranges = new List<Ip4Range> { new Ip4Range().Mask("10.0.0.0/25"), new Ip4Range().Mask("10.0.0.0/127") } } } } } }; var result = client.Search<ElasticsearchProject>(request); var agg = result.Aggs.IpRange("my_iprange_agg");
Refer to the {ref_current}/search-aggregations-bucket-iprange-aggregation.html[original docs] for more information.