> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Ask it with GET https://upstash.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash.com/docs/common/help/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash.com/docs/feedback?path=/docs/redis/search/query-operators/field-operators/boost&helpful=true` (or `false`) records whether this page helped. An optional `comment` (URL-encoded, at most 500 characters) says what was missing or wrong. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

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

<Tabs>

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

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

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

</Tabs>
