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.

With the required privileges, when you have a query pipeline created in your organization, you can use the Result Ranking tab of the query pipeline configuration to define query pipeline ranking expression rules 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 for each result item whose @brand field value is ACME when the query contains the terms monitor or screen.

Promoting ACME monitors

A user accesses the commerce portal and submits the following query: globex computer screen.

Even though the user is apparently searching for Globex-brand monitors, your ranking expression rule is likely to make ACME monitors appear higher in the result list.

Prerequisites

Before creating a rule, first make sure that you have the following:

Once you meet these requirements, you can create a rule on the Query Pipelines (platform-ca | platform-eu | platform-au) page. To test the rule, use the search page that uses the pipeline to which you added the rule. Alternatively, you can use the Content Browser (platform-ca | platform-eu | platform-au) page to ensure that the rule works as expected. To do so, on the Content Browser, select the pipeline to which you added the rule, and then perform queries to see the rule in action.

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
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 or edit ranking expression rules

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

  2. On the page that opens, select the Result Ranking tab, and then do one of the following:

    • To add a rule

      1. In the upper-right corner, click Add rule.

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

    • To edit a rule

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

  3. In the Content that matches section, depending on the mode, use either the dropdown menus or the input to enter or modify the desired filter expressions.

  4. 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 (meaning that the item score is neither lowered nor boosted).

    We recommend avoiding 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 relevance 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.

  5. 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 a group condition, type or select the desired group from the dropdown menu, or create a new one.

      Example

      Your Coveo-powered commerce portal at Barca Sports includes the Commerce query pipeline. This pipeline has both featured result and ranking expression rules for specific sport-related searches, such as "cycling equipment" or "skiing gear".

      These rules help promote different items to best suit the shopper’s Barca Sports profile. For instance, they promote starter cycling gear to beginner cyclists and advanced skiing equipment to self-described intermediate skiers.

      Since you’re promoting different products for different user profiles, you create two separate groups of query pipeline rules. Each group’s rules adjust the search results to align with the shopper’s expertise in their sport of interest.

      For more examples on creating groups of rules, see Common use cases.

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

  6. Review your ranking expression rule on the Preview test search page. For example:

    Coveo | result ranking preview

    Note that the customizations you made in the search interface builder (or the Interface Editor, if applicable) don’t apply in this preview.

    Tip

    You can move the slider under Will have its score changed by to see its effect on the ranking score in real time on the Preview test search page.

  7. Do one of the following:

    • If you created a new rule, click Add rule.

      • In the Name your rule input of the Rule information modal that opens, enter a name for your rule.

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

    • If you edited an existing rule, you have the option to rename or update the user note associated with your ranking expression rule:

      • In the upper-left corner, click Edit information.

      • In the Name your rule input of the Rule information modal that opens, review the name of your rule.

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

      • Click Save.

  8. Click Save.

The 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-ca | 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-ca | 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, select each checkbox next to the rules you want to duplicate within the same pipeline (typically to create a slightly different rule).

  4. In the Action bar, click Duplicate.

The duplicated rules 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-ca | 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-ca | 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, select each checkbox next to the rules 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 many 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 (for example, 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 dropdown 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 dropdown menu, select one of the available comparators.

  3. If applicable, in the Select a field value dropdown 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 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:

diagram showing order of execution

Required privileges

By default, members with the required privileges can view and edit elements of the Query Pipelines (platform-ca | platform-eu | platform-au) page.

The following table indicates the required privileges for members to view or edit ranking expressions (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