IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Histogram Aggregation Usage
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Histogram Aggregation Usage
editFluent DSL example
edita => a
.Histogram("commits", h => h
.Field(p => p.NumberOfCommits)
.Interval(100)
.MinimumDocumentCount(1)
.Order(HistogramOrder.KeyDescending)
.Offset(1.1)
)
Object Initializer syntax example
editnew HistogramAggregation("commits")
{
Field = Field<Project>(p => p.NumberOfCommits),
Interval = 100,
MinimumDocumentCount = 1,
Order = HistogramOrder.KeyDescending,
Offset = 1.1
}
Example json output.
{
"commits": {
"histogram": {
"field": "numberOfCommits",
"interval": 100.0,
"min_doc_count": 1,
"order": {
"_key": "desc"
},
"offset": 1.1
}
}
}
Handling Responses
editresponse.ShouldBeValid();
var commits = response.Aggregations.Histogram("commits");
commits.Should().NotBeNull();
commits.Buckets.Should().NotBeNull();
commits.Buckets.Count.Should().BeGreaterThan(0);
foreach (var item in commits.Buckets)
item.DocCount.Should().BeGreaterThan(0);