Custom ranking rules
With a custom ranking rule, you can put certain documents above others. So if you prefer to sell one product over another, you can use a custom ranking rule for this.
Attributes are the values of a document in Instant Search. You can use an attribute to sort the results if the relevance of certain documents is the same. If you search for "Shoe" and there are two products with the name "Shoe", they would both have the same relevance. By adding an attribute to both products, where one product gets the number '1' and the other product gets the number '2', a custom ranking rule can ensure that the shoe with 1 will be ranked above the shoe with 2.
The steps to set this up are explained below. In this example, we are working with a dataset of films for which we would like to influence the results so that they come back with the most recent release year first. We search for 'the lord of the rings'. You can see that the film with the release_year 2001 is on top.
Go to your source settings in the app environment and choose the 'Ranking Rules' tab. Click on 'Add rule' to open the screen below.
Choose the attribute you want to use for this ranking rule. It must be available in your dataset. In our case it is release_year. Then choose whether you want to sort the results ascending or descending based on the value of the attribute. In the case of release year, we wanted to sort descending. So that's what we select here.
You will see that a line is added where release_year is the name with a down arrow for descending sorting. Make sure that your own rule has been given the correct importance in the sorting of the rules.
If we then search the source again for 'The lord of the rings', we see that now the film with the release_year 2003 (the most recent one) is on top.