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.
Histogram Aggregation Usage
editHistogram Aggregation Usage
editFluent DSL example
edits => s .Aggregations(a => a .Histogram("commits", h => h .Field(p => p.NumberOfCommits) .Interval(100) .Missing(0) .Order(HistogramOrder.KeyDescending) ) )
Object Initializer syntax example
editnew SearchRequest<Project> { Aggregations = new HistogramAggregation("commits") { Field = Field<Project>(p => p.NumberOfCommits), Interval = 100, Missing = 0, Order = HistogramOrder.KeyDescending } }
Example json output.
{ "aggs": { "commits": { "histogram": { "field": "numberOfCommits", "interval": 100.0, "missing": 0.0, "order": { "_key": "desc" } } } } }
Handling Responses
editresponse.ShouldBeValid(); var commits = response.Aggs.Histogram("commits"); commits.Should().NotBeNull(); foreach (var item in commits.Buckets) item.DocCount.Should().BeGreaterThan(0);