Query Pipeline Management
- What's a Query Pipeline
- Routing Mechanisms and Rules
- Deployment Overview
- Order of Execution of Query Pipeline Features
- Troubleshooting Query Pipeline Rules
- Coveo ML Model Association Management
- Associate a Model via a JSON Configuration
- Thesaurus Rule Management
- Featured Results Rule Management
- Stop Words Rule Management
- Ranking Expressions Rule Management
- Ranking Weights Rule Management
- Triggers Rule Management
- Filters Rule Management
- Query Parameters Rule Management
- Query Pipeline Rule Management
- Coding Query Pipeline Rules
- Testing Changes
- Exporting and Importing Query Pipeline Elements
Adding and Managing Query Pipeline Ranking Expressions
A Coveo-powered search interface typically sorts query results by relevance. This means that items with high ranking scores normally appear on top of the result list. Members of the Administrators and Relevance Managers built-in groups can define query pipeline ranking expression rules to exercise direct control over item ranking scores.
You want to promote ACME monitors in a Coveo-powered commerce portal.
In the portal’s query pipeline, you define a ranking expression rule that adds a positive modifier to the ranking score of each result item whose
@brand field value is
ACME when the query contains
An end user accesses the commerce portal and submits the following query:
globex computer screen.
Even though the end user is apparently looking for monitors of the Globex brand, your ranking expression rule is now likely to make ACME monitors appear higher in the result list.
Common Use Cases
Among other things, you can use ranking expression rules to:
Promote new content related to a query.
Increase the ranking scores of items containing the most recent release notes when the end user submits a query containing
Enforce a business rule.
Increase the ranking scores of items aimed at customer retention when the end user submits a query containing
Demote content intended for another audience.
Reduce the ranking scores of developer-oriented items when the end user has identified themselves as an administrator.
Demote legacy content.
Reduce the ranking scores of all items related to a legacy product, unless the query contains that product name.
Consider the following leading practices when leveraging ranking expression rules:
Use ranking expression rules for legitimate reasons.
Ranking expression rules are especially useful when you need to enforce specific or temporary business rules which Coveo Machine Learning (Coveo ML) could otherwise hardly deduce from natural end-user behavior. By forcibly increasing or decreasing the ranking scores of certain query result items under certain circumstances, your goal should be to lead a significant number of end users to the most contextually relevant content, so that your Coveo ML models can eventually learn from those positive outcomes.
Use ranking expression rules sparingly.
Maintaining a large number of ranking expression rules in a solution can prove highly complex. When a rule is no longer useful, consider removing it. After a while, if a rule has actually been affecting the behavior of a significant number of end users, your Coveo ML models will typically adapt their output accordingly, often rendering the original rule obsolete.
Make your ranking expression rules just specific enough.
Normally, you should apply a condition to each ranking expression rule. Instead of creating rules that affect most, or all queries originating from a search interface, consider whether you can apply indexing techniques to improve relevance directly in your index. Also avoid creating rules that are too specific; if a rule merely applies to an insignificant volume of queries (e.g., one or two queries per month), it will likely not produce enough compelling usage analytics data for your Coveo ML models to learn anything meaningful.
Test your ranking expression rules.
Ranking expression rules can have unexpected side-effects. When you add a new rule in a query pipeline, it’s often a good idea to use A/B testing to validate whether this rule is affecting relevance as expected in your solution before allowing it to alter a significant volume of queries. You may also want to set-up an A/B test before definitively removing an existing rule from a query pipeline.
Adding a Rule
To add a ranking expression rule in a query pipeline
In the upper-right corner, click Add Rule, and then select Ranking expression rule*.
In the Add a Ranking Expression Rule panel that appears:
In the Matching expressions inputs, enter the desired expressions.
Select Boost or Lower to determine whether the rule should positively or negatively impact item ranking scores.
Click and drag the slider to the desired modifier value, or use the up and down arrows to increase or decrease the value by increments.
Click Add Rule. The new ranking expression rule is effective immediately.
*: (Advanced) You can instead select Ranking expressions with code to define the rule using the appropriate QPL syntax.
Managing Existing Rules
When creating a ranking expression rule with code or editing the code of an existing ranking expression rule, use the following query pipeline language (QPL) syntax:
Increase the ranking score of each item whose title contains Coveo by 100.
boost `@title/="^.*Coveo.*$"` by 10
Reduce the ranking score of each item that is older than a year, and of each item that is marked as obsolete, by 100; don’t modify the ranking score of an item if its current ranking score is already considered too low by the index.
boost `@date<today-1y`, `@isobsolete=="true"` by -10 with applyToEveryResults: false
The Coveo Cloud query syntax expressions whose result items should have their ranking scores modified by the rule.
When the rule applies, a distinct query ranking expression (QRE) is generated for each of those expressions.
When a rule contains an expression referencing a QPL object (e.g.,
@audience==$context.userRole), associate that rule with a query pipeline condition validating that the QPL object is populated with some value (e.g.,
when $context.userRole isPopulated). Otherwise, you risk modifying the ranking scores of unexpected items, as non-populated QPL objects are evaluated to the
A value indicating how much to boost or lower the ranking score of an item each time it appears in the result set of one of the rule’s expressions.
The modifier value is correlated to the ranking score of an item by a one to ten ratio (e.g., a modifier of
100 boosts the ranking score of each affected item by
1000). Setting the modifier to
0 renders the rule ineffective.
In the Coveo Cloud administration console, the minimum/maximum modifier value is +/-
1000 (in QPL, it’s +/-
Expected type (QPL): primitive (integer)
Avoid using modifiers greater than
100 or lower than
-100, unless you want to completely override the index ranking scores.
Options (QPL Only)
A hash in which each key must be a valid query ranking expression option, and each value must be of the expected type.
Whether to treat the
expression argument of each QRE generated by the rule as a constant expression (and cache its results).
When this option is set to
false, the modifier only applies to items whose current ranking score is considered high enough by the index.
Order of Execution
The following diagram highlights the position of ranking expression rules in the overall order of execution of query pipeline features.
|Action||Service - Domain||Required access level|
|View ranking expression rules||
Search - Query pipelines
|Edit ranking expression rules||
Search - Query pipelines