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.
Stats Aggregation Usage
editStats Aggregation Usage
editFluent DSL example
edits => s .Aggregations(a => a .Stats("commit_stats", st => st .Field(p => p.NumberOfCommits) ) )
Object Initializer syntax example
editnew SearchRequest<Project> { Aggregations = new StatsAggregation("commit_stats", Field<Project>(p => p.NumberOfCommits)) }
Example json output.
{ "aggs": { "commit_stats": { "stats": { "field": "numberOfCommits" } } } }
Handling Responses
editresponse.ShouldBeValid(); var commitStats = response.Aggs.Stats("commit_stats"); commitStats.Should().NotBeNull(); commitStats.Average.Should().BeGreaterThan(0); commitStats.Max.Should().BeGreaterThan(0); commitStats.Min.Should().BeGreaterThan(0); commitStats.Count.Should().BeGreaterThan(0); commitStats.Sum.Should().BeGreaterThan(0);