$cardinality returns the number of distinct values in a field.
All matching field values are deduplicated, then counted.
If missing is provided, documents without the field are treated as that fallback key
(which can increase the distinct count by at most one extra value).
Compatibility
| Field Type | Supported |
|---|---|
| TEXT | No |
| U64/I64/F64 | Yes |
| DATE | Yes |
| BOOL | Yes |
| KEYWORD | Yes |
| FACET | No |
FAST.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
field | string | Yes | Field to aggregate. |
missing | string | number | No | Fallback key for missing fields. |
- TypeScript
- Python
- Redis CLI