---
title: Relevance Tuning
description: Tune the BM25 score by adjusting the weights of individual queries
canonical: https://docs.paradedb.com/documentation/sorting/boost
---
## Boosting
ParadeDB offers several ways to tune a document's [BM25 score](/documentation/sorting/score).
The first is boosting, which increases or decreases the impact of a specific query by multiplying its contribution to the overall BM25 score.
To boost a query, cast the query to the `boost` type. In this example, the `shoes` query is weighted twice as heavily as the `footwear` query.
```sql SQL
SELECT id, pdb.score(id), description, category
FROM mock_items
WHERE description ||| 'shoes'::pdb.boost(2) OR category ||| 'footwear'
ORDER BY score DESC
LIMIT 5;
```
```python Django
from django.db.models import Q
from paradedb import Match, ParadeDB, Score
MockItem.objects.filter(
Q(description=ParadeDB(Match('shoes', operator='OR', boost=2))) |
Q(category=ParadeDB(Match('footwear', operator='OR')))
).annotate(
score=Score()
).values('id', 'score', 'description', 'category').order_by('-score')[:5]
```
```ruby Rails
MockItem.search(:description)
.matching_any("shoes", boost: 2)
.or(MockItem.search(:category).matching_any("footwear"))
.with_score
.select(:id, :description, :category)
.order(search_score: :desc)
.limit(5)
```
`boost` takes a numeric value, which is the multiplicative boost factor. It can be any floating point number between `-2048` and `2048`.
[Query builder functions](/documentation/query-builder/overview) can also be boosted:
```sql SQL
SELECT id, description, category, pdb.score(id)
FROM mock_items
WHERE description @@@ pdb.regex('key.*')::pdb.boost(2)
ORDER BY score DESC
LIMIT 5;
```
```python Django
from paradedb import ParadeDB, Regex, Score
MockItem.objects.filter(
description=ParadeDB(Regex('key.*', boost=2))
).annotate(
score=Score()
).values('id', 'description', 'category', 'score').order_by('-score')[:5]
```
```ruby Rails
MockItem.search(:description)
.regex("key.*", boost: 2)
.with_score
.select(:id, :description, :category)
.order(search_score: :desc)
.limit(5)
```
Boost can be used in conjunction with other type casts, like [fuzzy](/documentation/full-text/fuzzy):
```sql SQL
SELECT id, description, category, pdb.score(id)
FROM mock_items
WHERE description ||| 'shose'::pdb.fuzzy(2)::pdb.boost(2)
ORDER BY score DESC
LIMIT 5;
```
```python Django
from paradedb import Match, ParadeDB, Score
MockItem.objects.filter(
description=ParadeDB(Match('shose', operator='OR', distance=2, boost=2))
).annotate(
score=Score()
).values('id', 'description', 'category', 'score').order_by('-score')[:5]
```
```ruby Rails
MockItem.search(:description)
.matching_any("shose", distance: 2, boost: 2)
.with_score
.select(:id, :description, :category)
.order(search_score: :desc)
.limit(5)
```
## Constant Scoring
Constant scoring assigns the same score to all documents that match a query. To apply a constant score, cast the query to the `const` type with a
numeric value.
For instance, the following query assigns a score of `1` to all documents matching the query `shoes`.
```sql SQL
SELECT id, pdb.score(id), description, category
FROM mock_items
WHERE description ||| 'shoes'::pdb.const(1)
ORDER BY score DESC
LIMIT 5;
```
```python Django
from paradedb import Match, ParadeDB, Score
MockItem.objects.filter(
description=ParadeDB(Match('shoes', operator='OR', const=1))
).annotate(
score=Score()
).values('id', 'score', 'description', 'category').order_by('-score')[:5]
```
```ruby Rails
MockItem.search(:description)
.matching_any("shoes", constant_score: 1)
.with_score
.select(:id, :description, :category)
.order(search_score: :desc)
.limit(5)
```