// Promote 2 star trek objects when a query contains Star Wars
index.saveRule({
objectID: "promoteStarTrek",
condition: { pattern: "Star Wars", anchoring: "contains" },
consequence: {
promote: [
{ objectID: "5588602", position: 1 },
{ objectID: "3447500", position: 3 }
]
}
});
Discover Query Rules
Create a smarter, more natural search experience.
Query Rules allows you to enhance the ranking behavior of the engine for specific queries. You can set up rules to uncover and respond more specifically to the intent behind your users' queries.
Promote Results
Modify search ranking and promote specific results into desired positions.
Query-Based Alerts
Add promotional banners to alert users to offers and promotions relevant to their search queries.
Translate Intent
Guide users to the perfect result quickly with an as-you-type faceting experience
With Query Rules, you can promote, filter, and develop thousands of automatic triggers & rules based on context only you know to make sure your users get connected with what matters most.
Code with confidence
The what-is and how-to of the Query Rules API. Overviews, use cases, tutorials, code snippets, and a full tech reference - Everything you'll need to get started coding.
Query Rules DocsDo it visually
Access the “if this then that” Query Rules builder from within the Algolia Dashboard to start building your first rules today.
Login