> ## 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.

# $must

The `$must` operator requires all specified conditions to match.
Documents are only included in results if they satisfy every condition within the `$must` clause.
This implements logical AND behavior.

When you specify multiple field conditions at the top level of a query without any boolean operator,
they are implicitly wrapped in a `$must`. These queries are equivalent:

```ts theme={"system"}
// Implicit must
{ name: "headphones", inStock: true }

// Explicit $must
{ $must: { name: "headphones", inStock: true } }
```

### Syntax Options

The `$must` operator accepts either an object or an array:

* **Object syntax**: Each key-value pair is a condition that must match
* **Array syntax**: Each element is a separate condition object that must match

Array syntax is useful when you have multiple conditions on the same field
or when building queries programmatically.

### Examples

> [tab] TypeScript
>
> ```ts theme={"system"}
> // Explicit $must
> await products.query({
>   filter: {
>     $must: [{ name: "headphones" }, { inStock: true }],
>   },
> });
>
> // Equivalent implicit form
> await products.query({
>   filter: {
>     name: "headphones",
>     inStock: true,
>   },
> });
>
> // $must with object syntax
> await products.query({
>   filter: {
>     $must: {
>       name: "headphones",
>       inStock: true,
>     },
>   },
> });
> ```

> [tab] Python
>
> ```python theme={"system"}
> # Explicit $must
> products.query(filter={"$must": [{"name": "headphones"}, {"inStock": True}]})
>
> # Equivalent implicit form
> products.query(filter={"name": "headphones", "inStock": True})
>
> # $must with object syntax
> products.query(filter={"$must": {"name": "headphones", "inStock": True}})
> ```

> [tab] Redis CLI
>
> ```bash theme={"system"}
> # Explicit $must
> SEARCH.QUERY products '{"$must": [{"name": "headphones"}, {"inStock": true}]}'
>
> # Equivalent implicit form
> SEARCH.QUERY products '{"name": "headphones", "inStock": true}'
>
> # $must with object syntax
> SEARCH.QUERY products '{"$must": {"name": "headphones", "inStock": true}}'
> ```


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