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

# $max

`$max` returns the maximum field value across matching documents.

If `missing` is set, missing fields are treated as that value.

### Compatibility

| Field Type | Supported |
| - | - |
| TEXT | No |
| U64/I64/F64 | Yes |
| DATE | Yes |
| BOOL | Yes |
| KEYWORD | No |
| FACET | No |

Field must be `FAST`.

### Arguments

| Argument | Type | Required | Description |
| - | - | - | - |
| `field` | `string` | Yes | Field to aggregate. |
| `missing` | `number` | No | Fallback value for missing fields. |

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    await index.aggregate({
      aggregations: {
        most_expensive: { $max: { field: "price", missing: 0 } },
      },
    });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    index.aggregate(
        aggregations={"most_expensive": {"$max": {"field": "price", "missing": 0}}}
    )
    ```
  </Tab>

  <Tab title="Redis CLI">
    ```bash theme={null}
    SEARCH.AGGREGATE products '{}' '{"most_expensive": {"$max": {"field": "price", "missing": 0}}}'
    ```
  </Tab>
</Tabs>

### Output

```json theme={null}
{ "most_expensive": { "value": 80 } }
```

`value` can be `null` when no values are available.


## Related topics

- [ERR max request size exceeded](/redis/troubleshooting/max_request_size_exceeded.md)
- [ERR max requests limit exceeded](/redis/troubleshooting/max_requests_limit.md)
- [ERR max key size exceeded](/redis/troubleshooting/max_key_size_exceeded.md)
- [ERR max concurrent connections exceeded](/redis/troubleshooting/max_concurrent_connections.md)
- [ERR max daily request limit exceeded](/redis/troubleshooting/max_daily_request_limit.md)
