# $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
// 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

<Tabs>

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

<Tab title="Python">
```python
# 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>

<Tab title="Redis CLI">
```bash
# 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}}'
```
</Tab>

</Tabs>
