Extended Stats Aggregation Usage

edit

Fluent DSL example

edit
s => s
.Aggregations(a => a
    .ExtendedStats("commit_stats", es => es
        .Field(p => p.NumberOfCommits)
        .Sigma(1)
    )
)

Object Initializer syntax example

edit
new SearchRequest<Project>
{
    Aggregations = new ExtendedStatsAggregation("commit_stats", Field<Project>(p => p.NumberOfCommits)) { Sigma = 1 }
}

Example json output.

{
  "aggs": {
    "commit_stats": {
      "extended_stats": {
        "field": "numberOfCommits",
        "sigma": 1.0
      }
    }
  }
}

Handling Responses

edit
response.ShouldBeValid();
var commitStats = response.Aggs.ExtendedStats("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);
commitStats.SumOfSquares.Should().BeGreaterThan(0);
commitStats.StdDeviation.Should().BeGreaterThan(0);
commitStats.StdDeviationBounds.Should().NotBeNull();
commitStats.StdDeviationBounds.Upper.Should().BeGreaterThan(0);
commitStats.StdDeviationBounds.Lower.Should().NotBe(0);