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, they do not support perform numeric comparisons. This means they cannot be used with a range or conditions such as greater than (>), equal to (=) or less than (<) and the boosted attributes cannot hold a numeric value.
For example, if your records include an attribute such bestSeller:true
, you can use this as an optionalFilters
value. However, you cannot use a condition 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 certain number of times and apply optionalFilters
using that attribute.
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.