NOTE: You are looking at documentation for an older release. For the latest information, see the current release documentation.
Cardinality Aggregation Usage
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Cardinality Aggregation Usage
editFluent DSL example
edita => a
.Cardinality("state_count", c => c
.Field(p => p.State)
.PrecisionThreshold(100)
)
Object Initializer syntax example
editnew CardinalityAggregation("state_count", Field<Project>(p => p.State))
{
PrecisionThreshold = 100
}
Example json output.
{
"state_count": {
"cardinality": {
"field": "state",
"precision_threshold": 100
}
}
}
Handling Responses
editresponse.ShouldBeValid();
var projectCount = response.Aggregations.Cardinality("state_count");
projectCount.Should().NotBeNull();
projectCount.Value.Should().Be(3);