Promoting hits
How to promote hits using Rules.
You can use Rules to raise some results over others, or put one result or banner at the top of the results.
Promoting a single item
Use case
A book store wants to recommend a Harry Potter Box Set whenever the words Harry Potter form part of a search.
Rule
If query=Harry Potter then promote Harry Potter Box Set
By default, you can pin up to 300 items per rule.
Using the API
Using the dashboard
Visual Editor
-
Select the Search product icon on your dashboard and then select your index.
-
Select the Rules section from the left sidebar menu in the Algolia dashboard.
-
Under the heading Rules, select the index you are adding a Rule to.
-
Select Create your first rule or New rule. In the drop-down menu, click the Visual Editor option.
-
In the It all starts here section:
- Click Set search query button.
- In the side panel, type “Harry Potter” in the input field and click
Save
.
-
In the What do you want to do? section:
- Click the Pin item button.
- In the side panel, find the product ‘HP-12345’ you want to pin in the input field and press
Save
.
-
Review and publish your changes.
Manual Editor
-
Select the Rules section from the left sidebar menu in the Algolia dashboard.
-
Under the heading Rules, select the index you are adding a Rule to.
-
Select Create your first rule or New rule. In the drop-down menu, click the Manual Editor option.
-
In the Condition(s) section, keep Query contains and enter “Harry Potter” in the input field.
-
In the Consequence(s) section:
- Click the Add consequence button and select Pin an item.
- Find the product ‘HP-12345’ you want to pin the input field and press
Enter
.
-
Save your changes.
Promoting the newest release
Use case
You’ve placed “best-selling items” at the top of your search results by using Custom Ranking. But the newest release? Set up a Rule telling the engine that whenever iPhone is searched for, place the newest version at the top, but for the rest of the same brand phones, continue sorting by most-sold.
Rule
If query = iphone then promote newest iPhone release
Using the API
Using the dashboard
Visual Editor
-
Select the Search product icon on your dashboard and then select your index.
-
Select the Rules section from the left sidebar menu in the Algolia dashboard.
-
Under the heading Rules, select the index you are adding a Rule to.
-
Select Create your first rule or New rule. In the drop-down menu, click the Visual Editor option.
-
In the It all starts here section:
- Click Set search query button.
- In the side panel, type “iPhone” in the input field and click
Save
.
-
In the What do you want to do? section:
- Click the Pin item button.
- In the side panel, find the product “iPhone-12345” you want to pin in the input field and press
Save
.
-
Review and publish your changes.
Manual Editor
-
Select the Rules section from the left sidebar menu in the Algolia dashboard.
-
Under the heading Rules, select the index you are adding a Rule to.
-
Select Create your first rule or New rule. In the drop-down menu, click the Manual Editor option.
-
In the Condition(s) section, keep Query toggled on, select Contains in the drop-down menu, and enter “iPhone” in the input field.
-
In the Consequence(s) section:
- Click the Add consequence button and select Pin an item.
- Find the product “iPhone-12345” you want to pin the input field and press
Enter
.
-
Save your changes.
Promoting several results
Use case
You’re running a promotion on the newest Apple products. Set up a Rule telling the engine that whenever apple is searched for, place the newest releases at the top.
Rule
If query = apple then promote newest Apple releases
Using the API
Using the dashboard
Visual Editor
-
Select the Search product icon on your dashboard and then select your index.
-
Select the Rules section from the left sidebar menu in the Algolia dashboard.
-
Under the heading Rules, select the index you are adding a Rule to.
-
Select Create your first rule or New rule. In the drop-down menu, click the Visual Editor option.
-
In the It all starts here section:
- Click Set search query button.
- In the side panel, type “apple” in the input field and click
Save
.
-
In the What do you want to do? section:
- Click the Pin item button.
- In the side panel, click the Pin multiple items button.
- One per line, enter the object IDs you want to pin, “iPhone-12345” and “watch-123”, in the input field and press
Pin items
. - Click
Apply
.
-
Review and publish your changes.
Manual Editor
The Manual Editor only allows for pinning a single item at a time.
Promoting some results over others
Use case
Tomato: A simple search, but one that may never return the fruit (or vegetable) because too many Tomato Soup brands are selling better than cherry tomatoes.
Rule
If query=tomato then put fruits higher than the rest
Using the API
Using the dashboard
Visual Editor
-
Select the Search product icon on your dashboard and then select your index.
-
Select the Rules section from the left sidebar menu in the Algolia dashboard.
-
Under the heading Rules, select the index you are adding a Rule to.
-
Select Create your first rule or New rule. In the drop-down menu, click the Visual Editor option.
-
In the It all starts here section:
- Click Set search query button.
- In the side panel, type “tomato” in the input field and click
Save
.
-
In the What do you want to do? section:
- Click the Boost Categories button.
- In the side panel, type “food_group” in the input field for category, then “fruit” in the second input field and press Save.
-
Review and publish your changes.
Manual Editor
-
Select the Rules section from the left sidebar menu in the Algolia dashboard.
-
Under the heading Rules, select the index you are adding a Rule to.
-
Select Create your first rule or New rule. In the drop-down menu, click the Manual Editor option.
-
In the Condition(s) section, keep Query toggled on, select Contains in the drop-down menu, and enter “tomato” in the input field.
-
In the Consequence(s) section:
- Click the Add consequence button and select Add Query Parameter.
- Type
{"optionalFilters":"food_group:fruit"}
.
-
Save your changes.
Was this page helpful?