# $count

`$count` returns how many documents contribute a value for a field.

### How It Works

- By default, only documents that have the field are counted.
- If `missing` is set, documents without the field also contribute to result.

### Compatibility

| Field Type | Supported |
|------------|-----------|
| TEXT | No |
| U64/I64/F64 | Yes |
| DATE | Yes |
| BOOL | Yes |
| KEYWORD | Yes |
| FACET | No |

Field must be `FAST`.

### Arguments

| Argument | Type | Required | Description |
|----------|------|----------|-------------|
| `field` | `string` | Yes | Field to count values for. |
| `missing` | `number` | No | Fallback value for missing fields. |

<Tabs>

<Tab title="TypeScript">
```ts
await index.aggregate({
  aggregations: {
    price_count: { $count: { field: "price" } },
  },
});
```
</Tab>

<Tab title="Python">
```python
index.aggregate(
    aggregations={"price_count": {"$count": {"field": "price"}}}
)
```
</Tab>

<Tab title="Redis CLI">
```bash
SEARCH.AGGREGATE products '{}' '{"price_count": {"$count": {"field": "price"}}}'
```
</Tab>

</Tabs>

### Output

```json
{ "price_count": { "value": 9 } }
```
