Ip Range Aggregation Usageedit

Fluent DSL exampleedit

s => s
.Aggregations(a => a
    .IpRange("ip_ranges", ip => ip
        .Field(p => p.LeadDeveloper.IPAddress)
        .Ranges(
            r => r.To("10.0.0.5"),
            r => r.From("10.0.0.5")
        )
    )
)

Object Initializer syntax exampleedit

new SearchRequest<Project>
{
    Aggregations = new IpRangeAggregation("ip_ranges")
    {
        Field = Field((Project p) => p.LeadDeveloper.IPAddress),
        Ranges = new List<Nest.IpRange>
        {
            new Nest.IpRange { To = "10.0.0.5" },
            new Nest.IpRange { From = "10.0.0.5" }
        }
    }
}

Example json output. 

{
  "aggs": {
    "ip_ranges": {
      "ip_range": {
        "field": "leadDeveloper.iPAddress",
        "ranges": [
          {
            "to": "10.0.0.5"
          },
          {
            "from": "10.0.0.5"
          }
        ]
      }
    }
  }
}

Handling Responsesedit

response.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);