There may be occasions where you want your most popular products to appear higher in search results. There are a few methods you can use:
Use optional filters
Although you can use optionalFilters to boost items, these require a specific value and cannot be used with a range or any conditional logic such as greater than (>), equal to (=) or less than (<). Attributes for boosting need to be either a boolean or numeric value.
This means, if your records have an attribute such bestSeller:true
, you can use this as an optionalFilters value. However, you cannot use a value such as ordered_items>20
.
Instead, you can add additional logic to your script that adds a boolean attribute such as bestSeller
or adds a _tag
value of bestSeller
if an item has been ordered more than a specific number of times and use that with optionalFilters.
Create a custom ranking attribute
You can create a boosted
attribute that holds a boolean value and add this to your custom ranking formula as outlined here.
For more granular control, instead of a boolean attribute, you can specify a numeric attribute that maps to a boosted “level” as outlined here.
Note: Ensure you have set the order of the custom ranking boosted
attribute to descending.