$range groups documents into custom ranges.
Use it when bucket boundaries are defined by business logic (for example pricing tiers).
Compatibility
| Field Type | Supported |
|---|---|
| TEXT | No |
| U64/I64/F64 | Yes |
| DATE | Yes |
| BOOL | No |
| KEYWORD | No |
| FACET | No |
FAST.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
field | string | Yes | Field to bucket on. |
ranges | Array<{ key?: string, from?: number, to?: number }> | Yes | Non-empty array of range objects. |
keyed | boolean | No | If true, returns buckets as an object. Default: false. |
from is inclusive. to is exclusive.
- TypeScript
- Python
- Redis CLI
Output
fromAsString / toAsString and nested sub-aggregation outputs.