Ip Range Aggregation Usageedit

Fluent DSL exampleedit

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 exampleedit

new IpRangeAggregation("ip_ranges")
{
    Field = Field((Project p) => p.LeadDeveloper.IpAddress),
    Ranges = new List<IpRangeAggregationRange>
    {
        new IpRangeAggregationRange { To = "127.0.0.1" },
        new IpRangeAggregationRange { From = "127.0.0.1" }
    }
}

Example json output. 

{
  "ip_ranges": {
    "ip_range": {
      "field": "leadDeveloper.ipAddress",
      "ranges": [
        {
          "to": "127.0.0.1"
        },
        {
          "from": "127.0.0.1"
        }
      ]
    }
  }
}

Handling Responsesedit

response.ShouldBeValid();
var ipRanges = response.Aggregations.IpRange("ip_ranges");
ipRanges.Should().NotBeNull();
ipRanges.Buckets.Should().NotBeNull();
ipRanges.Buckets.Count.Should().Be(2);
ipRanges.Buckets.First().To.Should().Be("127.0.0.1");
ipRanges.Buckets.Last().From.Should().Be("127.0.0.1");
foreach (var range in ipRanges.Buckets)
{
    range.Key.Should().NotBeNullOrEmpty();
    range.DocCount.Should().BeGreaterThan(0);
}