How to boost or penalize a subset of records in the search results.
To boost or penalize records,
you need to add a boost attribute that tells Algolia how to rank them.Algolia doesn’t create this attribute for you:
it only uses the value you send.Boosted attributes can be boolean or numeric:
Boolean values create simple boosts.
Numeric values allow finer control over boosting.
The following examples use the featured attribute for boosting.
To run the code examples on this page, install the latest API client.
Custom ranking is the last criterion in Algolia’s ranking formula.
Add boost attributes here to affect the order of records with the same textual relevance.
It doesn’t override Algolia’s default ranking criteria.To boost records, add the attribute you’re boosting to the custom ranking from the dashboard or the API.
If your boosted attribute is a boolean,
ensure you set the order of the custom ranking attribute to descending.
You can sort records by an attribute before applying the ranking formula.For example, you might want results to appear in price-based groups (such as high-, medium-, and low-priced items).To do this,
assign numeric values (for example, 1, 2, and 3) to a defined grouping attribute.
Algolia sorts group 1 first, then group 2, and so on.
Use a separate attribute for grouping.
Don’t reuse your boost attribute.
This method uses sorting,
which applies before custom ranking and determines the overall group order.