> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-dx-3081-agentkit-tanstack-ai-backends.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# $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 theme={null}
    await index.aggregate({
      aggregations: {
        price_count: { $count: { field: "price" } },
      },
    });
    ```
  </Tab>

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

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

### Output

```json theme={null}
{ "price_count": { "value": 9 } }
```


## Related topics

- [VECTOR.COUNT](/redis/commands/vector/vector-count.md)
- [SEARCH.COUNT](/redis/commands/search/search-count.md)
- [Unexpected Increase in Command Count](/redis/troubleshooting/command_count_increases_unexpectedly.md)
- [Counting](/redis/search/counting.md)
- [$terms](/redis/search/aggregation-operators/bucket-aggregations/terms.md)
