boosted
attribute in the following dataset.
JSON
Data types of the boosted
attribute
Attributes for boosting need to be either a boolean or numeric value.
Ensure that the numeric value is not inside a string (Example:
"32"
).Initialize client
Set up an API client and send your data to AlgoliaUpdate the custom ranking
The last criterion of Algolia’s ranking formula iscustomRanking
. It lets you define a list of attributes used to rank the results in the case of textual relevance equality.
To boost featured fruits, you need to add the boosted
attribute to the custom ranking from the dashboard or the API.
Using the dashboard
On the ranking and sorting tab, add a new custom ranking attribute.
Using the API
When your
boosted
attribute is a boolean, ensure you have set the order of the custom ranking attribute to descending.More granular boosts
Now that thecustomRanking
is set, querying a
will return “almonds” first, as it matches both textually AND is a featured record.
If more granularity is necessary, a similar method can be used. Instead of a boolean attribute, you will need to specify a numeric attribute that maps to a boosted “level”.
In this case, the dataset might look like this:
JSON
customRanking
as it’s already set to rank by the boosted
attribute in descending order.
In this example, the query a
it will return “apple” first because it has the highest boosted
value.