Query rules are an if-this-then-that framework for using rules to customize your search results. Criteria is what determines if a rule fires and then actions determine the result of the rule. This allows users to modify the search engines in a rules-based way. Each experience can have any number of Query Rules.
When creating Query Rules, users need to specify certain criteria that will trigger a set of actions. If a query meets the conditions of a given Query Rule, the Search algorithm performs the actions specified in the rule to predetermine the search results based on the brand’s business needs.
For example, if a user searches for a specific search term you may want to display a hardcoded result or boost a set of entities. For additional details on Query Rules, and example use cases, visit the Query Rules Hitchhikers training module.
To add Query Rules in the UI:
- Click Search in the navigation bar and click on the desired Search experience.
- Click Query Rules.
- Click Add Query Rule. A dialog box appears.
- Enter the name of your rule.
- Then click + Add Criteria and select the criteria option that will trigger this rule. Then enter the specific details in the textbox.
- Click + Add Actions and select the action you want to trigger with this Rule.
- Click Save Query Rule.
To add Query Rules in the JSON Editor:
- Click Edit in JSON to navigate to your Search Configuration file.
- Within the
"rules"object enter the criteria needed to trigger the Query Rule and the desired action to be performed if the Query Rule criteria is met.
It should look something like this: