Value Count Aggregation Usage

edit

Fluent DSL example

edit
s => s
.Aggregations(a => a
    .ValueCount("commit_count", c => c
        .Field(p => p.NumberOfCommits)
    )
)

Object Initializer syntax example

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

Example json output.

{
  "aggs": {
    "commit_count": {
      "value_count": {
        "field": "numberOfCommits"
      }
    }
  }
}

Handling Responses

edit
response.IsValid.Should().BeTrue();
var commitCount = response.Aggs.ValueCount("commit_count");
commitCount.Should().NotBeNull();
commitCount.Value.Should().BeGreaterThan(0);