# Counting

The `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.

<Tabs>

<Tab title="TypeScript">
```ts
// 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>

<Tab title="Python">
```python
# Count all electronics
products.count(filter={"category": "electronics"})

# Count in-stock items under $100
products.count(filter={"inStock": True, "price": {"$lt": 100}})
```
</Tab>

<Tab title="Redis CLI">
```bash
# Count all electronics
SEARCH.COUNT products '{"category": "electronics"}'

# Count in-stock items under $100
SEARCH.COUNT products '{"inStock": true, "price": {"$lt": 100}}'
```
</Tab>

</Tabs>
