WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. 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
edits => s .Aggregations(a => a .Cardinality("state_count", c => c .Field(p => p.State) .PrecisionThreshold(100) ) )
Object Initializer syntax example
editnew SearchRequest<Project> { Aggregations = new CardinalityAggregation("state_count", Field<Project>(p => p.State)) { PrecisionThreshold = 100 } }
Example json output.
{ "aggs": { "state_count": { "cardinality": { "field": "state", "precision_threshold": 100 } } } }
Handling Responses
editresponse.ShouldBeValid(); var projectCount = response.Aggs.Cardinality("state_count"); projectCount.Should().NotBeNull(); projectCount.Value.Should().Be(3);
Was this helpful?
Thank you for your feedback.