Manage Ranking Expression Rules

A Coveo-powered search interface typically sorts query results by relevance. This means that items with high ranking scores normally appear at the top of the results list.

When you have the required privileges, you can use the Result Ranking tab of a query pipeline configuration to define query pipeline ranking expressionrules to exercise direct control over item ranking scores.

Example

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 monitor or screen.

1690 PromoteACMEMonitors

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:

Example

Increase the ranking scores of items containing the most recent release notes when the end user submits a query containing release notes or what’s new.

Example: a ranking expression rule promoting recent release notes

Enforce a Business Rule

Example

Increase the ranking scores of items aimed at customer retention when the end user submits a query containing cancel account.

Example: a ranking expression rule promoting customer retention content

Demote Content Intended for Another Audience

Example

Reduce the ranking scores of developer-oriented items when the end user has identified themselves as an administrator.

Example: a ranking expression rule demoting developer-oriented content

Demote Legacy Content

Example

Reduce the ranking scores of all items related to a legacy product, unless the query contains that product name.

Example: a ranking expression rule demoting content related to a legacy product

Create Ranking Expression Rules

  1. On the Query Pipelines (platform-eu | platform-au) page, click the query pipeline in which you want to add a rule, and then click Edit components in the Action bar.

  2. On the page that opens, select the Result Ranking tab, and then, in the upper-right corner, click Add rule.

  3. In the Add Ranking Rule modal that opens, select Ranking expression.

  4. In the Content that matches section, depending on the mode, use the drop-down menus or the input to provide the desired filter expressions.

  5. Under Will have its score changed by, move the slider to lower or boost the score of items that meet the specified filter expressions. The default score is 0.

    We recommend avoiding using modifiers greater than 100 or lower than -100, unless you want to completely override the index ranking scores. If you want to make a specific item appear at the top of the search results, you should consider using featured result rules instead.

    Important

    The selected score value affects the final search result ranking score by a 1 to 10 ratio.

    For example, if you select to boost the score of items that meet the specified filter expressions by a score of 100, this expression adds 1,000 to the final search result ranking score of matching items.

  6. Under If the following conditions are met, you can optionally associate your ranking expression rule to a group of rules or assign a query pipeline condition:

    • To associate your ranking expression rule to a group of rules, under Use group’s condition, type or select the desired group from the drop-down menu, or create a new one.

    • To assign a query pipeline condition to your ranking expression rule, under Use independent condition, type or select the desired condition from the drop-down menu, or create a new one.

  7. Review your ranking expression rule in the Preview test search page. Note that the customizations you made in the search interface builder (or the Interface Editor, if applicable) don’t apply in this preview.

  8. Click Add rule.

  9. In the Rule information modal that opens:

    • In the Name your rule input, enter a name for your rule.

    • In the User notes input, optionally enter text with information that could help you and your colleagues to manage the rule in the future.

  10. Click Save.

The new rule is effective immediately.

Edit Ranking Expression Rules

  1. On the Query Pipelines (platform-eu | platform-au) page, click the query pipeline in which you want to edit a rule, and then click Edit components in the Action bar.

  2. On the page that opens, select the Result Ranking tab.

  3. Click the rule you want to edit, and then click Edit in the Action bar.

  4. In the Content that matches section, depending on the mode, use the drop-down menus or the input to update the desired filter expressions.

  5. Under Will have its score changed by, move the slider to lower or boost the score of items that meet the specified filter expressions. The default score is 0.

    We recommend avoiding using modifiers greater than 100 or lower than -100, unless you want to completely override the index ranking scores. If you want to make a specific item appear at the top of the search results, you should consider using featured result rules instead.

    Important

    The selected score value affects the final search result ranking score by a 1 to 10 ratio.

    For example, if you select to boost the score of items that meet the specified filter expressions by a score of 100, this expression adds 1,000 to the final search result ranking score of matching items.

  6. Under If the following conditions are met, you can optionally associate your ranking expression rule to a group of rules or assign a query pipeline condition:

    • To associate your ranking expression rule to a group of rules, under Use group’s condition, type or select the desired group from the drop-down menu, or create a new one.

    • To assign a query pipeline condition to your ranking expression rule, under Use independent condition, type or select the desired condition from the drop-down menu, or create a new one.

  7. Review your ranking expression rule in the Preview test search page. Note that the customizations you made in the search interface builder (or the Interface Editor, if applicable) don’t apply in this preview.

  8. (Optional) If you want to rename or update the user notes associated to your ranking expression rule, in the top-left corner, click Edit information.

    In the Rule information modal that opens:

    1. In the Name your rule input, review the name of your rule.

    2. In the User notes input, optionally enter text with information that could help you and your colleagues to manage the rule in the future.

    3. Click Save.

  9. Click Save.

The new rule is effective immediately.

Modify Ranking Expression JSON Configuration

Editing a rule JSON configuration is especially useful when you want to implement a rule that doesn’t fit with the parameters available in the Coveo Administration Console. . On the Query Pipelines (platform-eu | platform-au) page, click the query pipeline for which you want to modify existing query pipeline rules, and then click Edit components in the Action bar.

  1. On the page that opens, select the Result Ranking tab.

  2. In the Result Ranking tab, click the rule you want to modify, and then click Edit JSON in the Action bar.

  3. On the Edit a Ranking Expression JSON Rule subpage, make the desired modifications.

  4. Click Save.

Duplicate Ranking Expression Rules

  1. On the Query Pipelines (platform-eu | platform-au) page, click the query pipeline for which you want to duplicate query pipeline rules, and then click Edit components in the Action bar.

  2. On the page that opens, select the Result Ranking tab.

  3. In the Result Ranking tab, click the rule you want to duplicate within the same pipeline (typically to create a slightly different rule).

  4. In the Action bar, click Duplicate.

The duplicated rule appears at the bottom of the list in the pipeline component tab.

Review Information About the Rule’s Creation or Last Modification

You can verify who created or last modified a given ranking expression rule by inspecting the Details column of the Result Ranking tab. The Details column also indicates the hour and date the rule was created or last modified.

  1. On the Query Pipelines (platform-eu | platform-au) page, click the query pipeline containing the rule for which you want to inspect the information of the Details column, and then click Edit components in the Action bar.

  2. On the page that opens, select the Result Ranking tab.

  3. In the Result Ranking tab, inspect the information of the Details column for the desired rule.

Delete Ranking Expression Rules

  1. On the Query Pipelines (platform-eu | platform-au) page, click the query pipeline for which you want to delete query pipeline rules, and then click Edit components in the Action bar.

  2. On the page that opens, select the Result Ranking tab.

  3. In the Result Ranking tab, click the rule that you want to delete.

  4. Click Delete to confirm.

Leading Practices

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. In addition, ranking expression rules require a significant amount of processing power, so using many of them can slow down the search response time.

Tip
Leading practice

If one or more of your ranking expression rules are only relevant for a specific period of time, you should consider including them in a campaign group. This feature lets you specify a period of time for which the rules must be effective. When the specified end date is reached, targeted rules are automatically deactivated.

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.

Reference

Operators

Contains

For the ranking expressions to modify the ranking score of the search results of an end user, the expression entered in the Enter keyword(s) input must be part of the end user query.

Is

For the ranking expressions to modify the ranking score of the search results of an end user, the expression entered in the Enter keyword(s) input must be the same as the end user query.

Matches

(For advanced users) For the ranking expressions to modify the ranking score of the search results of an end user, their query must match the regular expression (regex) entered in the Enter keyword(s) input.

"Content that matches" Section

When creating a rule, under the Content that matches section, you must define filter expressions for which matching result items should have their ranking scores modified by the rule.

You can define filter expressions using either the "Basic Mode" or "Advanced Mode".

Basic Mode

To define filter expressions using the Basic Mode:

  1. In the Select field drop-down menu, use the Filter box to find and select the field that must be targeted by the filter expression.

  2. In the Select a comparator drop-down menu, select one of the available comparators.

  3. If applicable, in the Select a field value drop-down menu, enter or select the values that must be filtered according to the field selected in step 1.

  4. (Optional) Click Add to add another filter expression to the rule. Note that when adding multiple filter expressions to a rule, new filter expressions are appended to the initial expression using the and logic, meaning that only content matching all filter expressions will be affected by the rule.

Example

In the following capture, only items whose author is Coveo and which were created or updated in the last month will be affected by the rule.

content that matches section

Advanced Mode

To define filter expressions using the Advanced Mode, enter a query expression using the Coveo query syntax.

Example

In the following capture, only items whose author is Coveo and which were created or updated in the last month will be affected by the rule.

content that match section

Order of Execution

The following diagram illustrates the overall order of execution of query pipeline features:

order of pipeline execution

Required Privileges

By default, members of the Administrators and Relevance Managers built-in groups can view and edit elements of the Query Pipelines (platform-eu | platform-au) page.

The following table indicates the required privileges to view or edit ranking expressions rules (see Manage Privileges and Privilege Reference).

Action Service - Domain Required access level

View ranking expressions rules

Organization - Organization
Search - Query pipelines

View

Edit ranking expressions rules using the Basic mode

Organization - Organization
Content - Fields

View

Search - Query pipelines

Edit

Search - Execute queries

Allowed

Edit ranking expressions rules using the Advanced mode

Organization - Organization

View

Search - Query pipelines

Edit

Search - Execute queries

Allowed