> ## Documentation Index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Counting

The [`SEARCH.COUNT`](https://upstash.com/docs/redis/commands/search/search-count) command returns the number of documents matching a query without retrieving them.

You can use `SEARCH.COUNT` for analytics, pagination UI (showing "X results found"),
or validating queries before retrieving results.

> [tab] TypeScript
>
> ```ts theme={"system"}
> // Count all electronics
> await products.count({
>   filter: {
>     category: "electronics",
>   },
> });
>
> // Count in-stock items under $100
> await products.count({
>   filter: {
>     inStock: true,
>     price: { $lt: 100 },
>   },
> });
> ```

> [tab] Python
>
> ```python theme={"system"}
> # Count all electronics
> products.count(filter={"category": "electronics"})
>
> # Count in-stock items under $100
> products.count(filter={"inStock": True, "price": {"$lt": 100}})
> ```

> [tab] Redis CLI
>
> ```bash theme={"system"}
> # Count all electronics
> SEARCH.COUNT products '{"category": "electronics"}'
>
> # Count in-stock items under $100
> SEARCH.COUNT products '{"inStock": true, "price": {"$lt": 100}}'
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.