Max Aggregation Usage

edit

Fluent DSL example

edit
s => s
.Aggregations(a => a
    .Max("max_commits", m => m
        .Field(p => p.NumberOfCommits)
    )
)

Object Initializer syntax example

edit
new SearchRequest<Project>
{
    Aggregations = new MaxAggregation("max_commits", Field<Project>(p => p.NumberOfCommits))
}

Example json output.

{
  "aggs": {
    "max_commits": {
      "max": {
        "field": "numberOfCommits"
      }
    }
  }
}

Handling Responses

edit
response.ShouldBeValid();
var max = response.Aggs.Max("max_commits");
max.Should().NotBeNull();
max.Value.Should().BeGreaterThan(0);