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

# $boost

The `$boost` operator adjusts the relevance score contribution of a field match.
This allows you to prioritize certain matches over others in the result ranking.

### How Boosting Works

Search results are ordered by a relevance score that reflects how well each document matches the query.
By default, all matching conditions contribute equally to this score.
The `$boost` operator multiplies a match's score contribution by the specified factor.

* **Positive values greater than 1** increase the match's importance (e.g., `$boost: 2.0` doubles the contribution)
* **Values between 0 and 1** decrease the match's importance
* **Negative values** demote matches, pushing them lower in results

### Use Cases

* **Prioritize premium content:** Boost matches in title fields over body text
* **Promote featured items:** Give higher scores to promoted products
* **Demote less relevant matches:** Use negative boosts to push certain matches down

### Compatibility

The `$boost` operator can be used with any field type since it modifies the score rather than the matching behavior.

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

### Examples

> [tab] TypeScript
>
> ```ts theme={"system"}
> // Boost matches in $should clauses to prioritize certain terms
> await products.query({
>   filter: {
>     $must: {
>       inStock: true,
>     },
>     $should: [
>       { description: "premium", $boost: 10.0 },
>       { description: "quality", $boost: 5.0 },
>     ],
>   },
> });
>
> // Demote budget items with negative boost
> await products.query({
>   filter: {
>     $must: {
>       category: "electronics",
>     },
>     $should: [
>       { name: "featured", $boost: 5.0 },
>       { description: "budget", $boost: -2.0 },
>     ],
>   },
> });
> ```

> [tab] Python
>
> ```python theme={"system"}
> # Boost matches in $should clauses to prioritize certain terms
> products.query(filter={
>     "$must": {"inStock": True},
>     "$should": [
>         {"description": "premium", "$boost": 10.0},
>         {"description": "quality", "$boost": 5.0},
>     ],
> })
>
> # Demote budget items with negative boost
> products.query(filter={
>     "$must": {"category": "electronics"},
>     "$should": [
>         {"name": "featured", "$boost": 5.0},
>         {"description": "budget", "$boost": -2.0},
>     ],
> })
> ```

> [tab] Redis CLI
>
> ```bash theme={"system"}
> # Boost matches in $should clauses to prioritize certain terms
> SEARCH.QUERY products '{"$must": {"inStock": true}, "$should": [{"description": "premium", "$boost": 10.0}, {"description": "quality", "$boost": 5.0}]}'
>
> # Demote budget items with negative boost
> SEARCH.QUERY products '{"$must": {"category": "electronics"}, "$should": [{"name": "featured", "$boost": 5.0}, {"description": "budget", "$boost": -2.0}]}'
> ```


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