Rules

Rules in a Search API serve as user-defined instructions designed to execute specific actions based on the query, a particular page, or across all queries. Their primary benefit is reducing the occurrence of null results, which are not favorable for end users.

Following are the three types of rules that can be configured:

Query Rules: These are specific to individual search queries. They modify the search results or trigger actions based on the terms used in the query. For example, if a user searches for "winter jackets," a query rule could prioritize items on sale, highlight certain brands, or suggest related categories like "winter accessories."

Page Rules: These apply to specific pages or sets of pages rather than individual queries. For instance, a page rule might be set on a sale page to automatically promote items with the highest discount or to filter out products that are not part of the sale, enhancing the relevance of the page content to the user's browsing intent.

Global Rules: These are broad rules that apply to all search queries and pages. They ensure a consistent search experience across the platform. For example, a global rule could be set to always exclude discontinued products from search results, or to boost the visibility of new arrivals regardless of the specific search query.

Each type of rule allows for a tailored and efficient search experience, aligning results more closely with user intent and reducing the likelihood of encountering irrelevant or null results.