Cardinality Aggregation Usage

edit

Fluent DSL example

edit
a => a
.Cardinality("state_count", c => c
    .Field(p => p.State)
    .PrecisionThreshold(100)
)

Object Initializer syntax example

edit
new CardinalityAggregation("state_count", Field<Project>(p => p.State))
{
    PrecisionThreshold = 100
}

Example json output.

{
  "state_count": {
    "cardinality": {
      "field": "state",
      "precision_threshold": 100
    }
  }
}

Handling Responses

edit
response.ShouldBeValid();
var projectCount = response.Aggregations.Cardinality("state_count");
projectCount.Should().NotBeNull();
projectCount.Value.Should().Be(3);