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.
Ip Range Aggregation Usage
editIp Range Aggregation Usage
editFluent DSL example
edits => s .Aggregations(a => a.IpRange("ip_ranges", ip => ip .Field(p => p.LeadDeveloper.IPAddress) .Ranges( r => r.To("127.0.0.1"), r => r.From("127.0.0.1") ) ))
Object Initializer syntax example
editnew SearchRequest<Project> { Aggregations = new IpRangeAggregation("ip_ranges") { Field = Field((Project p) => p.LeadDeveloper.IPAddress), Ranges = new List<Nest.IpRange> { new Nest.IpRange { To = "127.0.0.1" }, new Nest.IpRange { From = "127.0.0.1" } } } }
Example json output.
{ "aggs": { "ip_ranges": { "ip_range": { "field": "leadDeveloper.iPAddress", "ranges": [ { "to": "127.0.0.1" }, { "from": "127.0.0.1" } ] } } } }
Handling Responses
editresponse.ShouldBeValid(); var ipRanges = response.Aggs.IpRange("ip_ranges"); ipRanges.Should().NotBeNull(); ipRanges.Buckets.Should().NotBeNull(); ipRanges.Buckets.Count.Should().BeGreaterThan(0); foreach (var range in ipRanges.Buckets) range.DocCount.Should().BeGreaterThan(0);