Search result boosting

Current version: 9.0

In Sitecore XP, there are two ways to boost search results - query-time boosting and index-time boosting.

 

Query-time boosting

Query-time boosting lets you control the contents and ranking of the search results of individual queries at runtime. The context of the user when they invoke the search query provides information that is not available when the index is compiled, and this provides greater opportunities for dynamic interaction. For example, you can amplify or reduce the boosting value of a field when you invoke a search query based on location, visit number, persona, purchase history, and so on. Query-Time boosting is currently only available in the LINQ layer must therefore be implemented by developers.

Here is an example:

SOLR syntax

LINQ to Sitecore

_name:Sitecore^4 CMS

.Where(c => c.Name.Equals("Sitecore").Boost(4) || c.Name.Equals("CMS"))

This example returns results that have the word Sitecore or CMS, or both in the item name and the items that have Sitecore in the item name are listed higher in the search results than the items that have CMS in the name.

Note

Search engines take the length of a field into consideration. an item named CMS could still appear higher in the search results than an item named, for example, Sitecore is also a marketing automation tool.

Query-time boosting:

  • Is more precise than index-time boosting.

  • Can be applied per query.

  • Can be changed without having to rebuild the entire index.

Index-time boosting

Important

Search result boosting works in Solr version 6.6 or earlier. However, Solr removed support for index-time boosting in Solr 7. As a result, field-level boosting is no longer supported and any boosts that are provided are ignored by Solr.

In Sitecore XP 10.0.0 or later, item-level boosting relies on index-time scoring factors that are indexed in the __boost field and combined with the query score using the query _val_:__boost function.

You can boost specific items and fields when they are indexed. These items and fields will get a higher score than other items and fields. You can use boosting, for example, to promote the most popular or the most sold books in a bookshop in a search result.

You can apply boosting at an item level or a field level.

You use field-level boosting to specify that matches on some fields are more or less important than matches on other fields. For example, for a bookshop, the book product item has three fields: Title, Summary and Foreword. When searching, matches in the Foreword field should be less important than matches in the Title and Summary fields.

Note

You can also apply boosting at query time. This boosting also takes effect for items or fields that you have boosted at indexing time.

Field-level boosting

The indexing.resolveFieldBoost pipeline resolves field-level boosting. The following processors are enabled in this pipeline:

RequestResponse
<processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
   ResolveFieldBoost.SystemFieldFilter, Sitecore.ContentSearch"/>
<processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
  ResolveFieldBoost.FieldDefinitionItemResolver, Sitecore.ContentSearch"/>
<processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
  ResolveFieldBoost.StaticFieldBoostResolver, Sitecore.ContentSearch"/>

The SystemFieldFilter processor ensures that all the system fields are ignored (fields with names that start with the “__” characters).

The FieldDefinitionItemResolver processor resolves the field-definition item that provides the boost value.

Once the template definition item has been resolved, the StaticFieldBoostResolver is started. This processor reads the boost value from the field-definition item.

To see the Indexing section of items, you must select the Standard Fields check box on the View tab in the Content Editor.

Configuration

You configure boosting in the Sitecore.ContentSearch.config in the Website\App_Config\Include folder. When you configure boosting, note the following:

  • Default value for Boost is 1.

  • Values greater than 1 lift results to the top.

  • Values less than 1 move results to the bottom.

    RequestResponse
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <sitecore>
        ...
        <pipelines>
          <!-- RESOLVE FIELD LEVEL BOOSTING
               Pipeline for resolving boosting rules on fields.
               Arguments: (Item) Item being indexed
               Example : Boost search results by a field value.
          -->
          <indexing.resolveFieldBoost help="Processors should derive from 
                    Sitecore.ContentSearch.Pipelines.ResolveBoost.ResolveFieldBoost.
                    BaseResolveFieldBoostPipelineProcessor">
             <processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost
                    .ResolveFieldBoost.SystemFieldFilter, Sitecore.ContentSearch"/>
             <processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
                     ResolveFieldBoost.FieldDefinitionItemResolver, Sitecore.ContentSearch"/>
             <processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
                     ResolveFieldBoost.StaticFieldBoostResolver, Sitecore.ContentSearch"/>
          </indexing.resolveFieldBoost>
          <!-- RESOLVE ITEM LEVEL BOOSTING
               Pipeline for resolving boosting rules on items.
               Arguments: (Item) Item being indexed
               Example : Boost search results by an Item Template.
          -->
          <indexing.resolveItemBoost help="Processors should derive from
                  Sitecore.ContentSearch.Pipelines.ResolveBoost.
                  ResolveItemBoost.BaseResolveItemBoostPipelineProcessor">
            <processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
                    ResolveItemBoost.ItemLocationFilter, Sitecore.ContentSearch">
               <includedLocations hint="list">
                  <content>/sitecore/content</content>
                  <media>/sitecore/media library</media>
               </includedLocations>
            </processor>
            <processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
                    ResolveItemBoost.StaticItemBoostResolver, Sitecore.ContentSearch"/>
            <processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
                    ResolveItemBoost.LocalRuleBasedItemBoostResolver, Sitecore.ContentSearch"/>
            <processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
                    ResolveItemBoost.GlobalRuleBasedItemBoostResolver, Sitecore.ContentSearch"/>
          </indexing.resolveItemBoost>
        </pipelines>
        <!-- BOOSTING MANAGER
             The manager class controlling the boosting resolution logic
        -->
        <boostingManager defaultProvider="default" enabled="true">
          <providers>
            <clear/>
            <add name="default" type="Sitecore.ContentSearch.Boosting.
                    PipelineBasedBoostingProvider, Sitecore.ContentSearch"/>
          </providers>
        </boostingManager>
        ...
      </sitecore>
    </configuration>

Item-level boosting

The indexing.resolveItemBoost pipeline resolves item-level boosting. The following processors are enabled in this pipeline:

RequestResponse
<processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
      ResolveItemBoost.ItemLocationFilter, Sitecore.ContentSearch">
    <includedLocations hint="list">
      <content>/sitecore/content</content>
      <media>/sitecore/media library</media>
    </includedLocations>
</processor>
<processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
      ResolveItemBoost.StaticItemBoostResolver, Sitecore.ContentSearch"/>
<processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
      ResolveItemBoost.LocalRuleBasedItemBoostResolver, Sitecore.ContentSearch"/>
<processor type="Sitecore.ContentSearch.Pipelines.ResolveBoost.
      ResolveItemBoost.GlobalRuleBasedItemBoostResolver, Sitecore.ContentSearch"/>

The ItemLocationFilter processor ensures that only items in the specified locations are processed by the pipeline. You can extend this list in this way:

RequestResponse
<includedLocations hint="list">
   <content>/sitecore/content</content>
   <media>/sitecore/media library</media>
   <custom>/sitecore/custom</custom>
</includedLocations>

The StaticItemBoostResolver processor reads the boost value of the indexed item.

This value can also be set for all items based on a template using __Standard Values fields. To see the Indexing section of items, you must select the Standard Fields check box on the View tab in the Content Editor. The Boost Value field is in this section.

Rule-based boosting

The LocalRuleBasedItemBoostResolver and the GlobalRuleBasedItemBoostResolver processors provide rule-based boosting for indexed items. These two processors are both executed using the rules engine. They look up boosting rules in different locations:

  • The LocalRuleBasedItemBoostResolver processor reads rules from the Boosting rules field in the Indexing section.

    The source of the Boosting rules field is restricted to the following location where all boosting rules are managed:

    /sitecore/system/Settings/Rules/Indexing and Search/Item Rules

    This set of boosting rules can also be set on the __Standard Values level, just as other field values.

  • The GlobalRuleBasedItemBoostResolver processor processes all boosting rules created under /sitecore/system/Settings/Indexing and Search/Rules/Global Rules.

For performance reasons, use the local boosting rules as much as possible.

Create a boosting rule

You can create a boosting rule that is used locally per item, or a global rule. You create global boosting rules as children of the Global Rules item; you create local boosting rules as children of the Item Rules item.

To create a boosting rule:

  1. Navigate to this item in the content tree:

    /sitecore/system/Settings/Rules/Indexing and Search/

  2. To create a new local item rule, right-click on the Item Rules item and then click Insert,Boosting Rule:

  3. In the Message dialog, enter a name for the new rule. For example, you can create a boosting rule that boosts all items in English:

  4. Select the new rule and in the Data section, click Edit rule. The Rule Set Editor opens:

  5. Select the conditions for your rule. For example, to create a rule that boosts all items in English, in the Item Version section, select the where the item language compares to value condition from the list and then edit the condition as follows:

  6. In the Indexing & Search section, select the adjust boost by select action:

  7. In the Rule description section, click select and adjust the boost value. The boost value can be either a positive or a negative number.

Do you have some feedback for us?

If you have suggestions for improving this article,