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.
Date Histogram aggregationedit
A multi-bucket aggregation similar to the histogram except it can only be applied on date values.
Fluent DSLedit
var result = _client.Search<ElasticsearchProject>(s => s .Aggregations(a => a .DateHistogram("my_date_histogram", h => h .Field(p => p.StartedOn) .Interval("month") ) ) ); var agg = result.Aggs.DateHistogram("my_date_histogram");
Object Initializer Syntaxedit
var request = new SearchRequest { Aggregations = new Dictionary<string, IAggregationContainer> { { "my_date_histogram", new AggregationContainer { DateHistogram = new DateHistogramAggregator { Field = "startedOn", Interval = "month" } } } } }; var result = client.Search<ElasticsearchProject>(request); var agg = result.Aggs.DateHistogram("my_date_histogram");
Refer to the {ref_current}/search-aggregations-bucket-datehistogram-aggregation.html[original docs] for more information.