Cardinality aggregation #
A single-value metrics aggregation that counts the number of distinct (approximate) values of a field.
Examples #
POST /sales/_search
{
"aggs": {
"type_count": {
"cardinality": {
"field": "type"
}
}
}
}
Response:
{
...
"aggregations": {
"type_count": {
"value": 3
}
}
}
Parameters for cardinality
#
field
(Required, string) Field you wish to aggregate.missing
(Optional, value) Value used for documents missing the field; all such documents count as one distinct value.