Search result boosting

Last updated Tuesday, April 12, 2016 in Sitecore Experience Platform for Developer, Administrator

You can boost specific items and fields when they are indexed at indexing time. These items and fields will score better 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.

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.
    <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>

Field-level boosting

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

<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.

Item-level boosting

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

<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:

<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:

    Picture 3

  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:

    Picture 5

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

    Picture 10

  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:

    Picture 9

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

    Picture 11

  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.