LibrarySites.Banner

Sitecore 7: Six Types of Search Boosting

The concept of scoring is integral to the new search features in version 7 of the Sitecore ASP.NET web Content Management System (CMS). You can think of scoring as a way to determine the importance of each item relative to other items. You can control scoring to leverage the search engine to your greatest advantage. Before you read this blog post, please read the Sitecore 7: Introduction blog post linked in the Resources section at the end of this page.

Introduction

You can implement solutions that take advantage of dynamic circumstances. For example, you could affect the scoring of products matching search terms to promote specific products, such as those with high prices, volume discounts, or prices on one end of a weighted range.

Several features of Sitecore 7 facilitate dynamic requirements by reducing the complexity of the underlying logical frameworks, such as scoring. By default, Sitecore does nothing to boost (affect) the relative score of any item or field, indicating no bias. In this case, the index can still take field names and values into consideration when determining the score for a document (item) or field, which you should consider when naming your data template fields and hence the default field names in your index and when you set the name of a field in the index explicitly. For example, the index may expect fields with short names to contain the most relevant information. Scoring rules are typically the responsibility of the indexing provider.

Sitecore 7 supports six boosting techniques:

  1. Field Boosting
  2. Field Type Boosting
  3. Item boosting
  4. Rules-Based Item Boosting
  5. Global Rules-Based Item Boosting
  6. Query-Time Boosting

Boosting occurs in different ways at different times (for example, when indexing or querying), giving users, developers and administrators complete control over how to present their data at runtime. Under the default configuration, at indexing time, Sitecore applies a value of one (1) as the boost for each item.

1. Field Boosting

You can boost the importance of specific fields. For example, you may want to boost the value of specific fields, such as title or abstract. Field boosting applies at indexing time, making it efficient but static. Set the boost attribute of the relevant /configuration/sitecore/contentSearch/configuration/DefaultIndexConfiguration/fieldMap/fieldNames/fieldName element in the Web.config file, typically specified in the /App_Config/Include/Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config Web.config include file. All indexes share this configuration by default.

2. Field Type Boosting

You can boost the importance of specific types of fields. For example, a search hit on a value in a single-line text field might be more important than a hit in a rich text field. Field type boosting applies at indexing time, meaning it is efficient but static. Set the boost attribute of the relevant /configuration/sitecore/contentSearch/configuration/DefaultIndexConfiguration/fieldMap/fieldType/fieldType element in the Web.config file, typically specified in /App_Config/Include/Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config.

3. Item Boosting

You can boost entire items, including all fields in all versions of all languages. This approach is static, but can be extremely efficient, for example when you want to promote one variant of a product above another. To set the boost value for an item, show the fields of the standard template, and then in the Indexing section, enter a numerical value in the field named Boost Value. Update 27.Oct.2014: To reduce the default boost value for a type of item, set the Boost Value to a very low positive number in the standard values for that data template. For example, to reduce the potential for folders appearing in search results, in standard values for the Common/Folder data template, set the Boost Value to .01. Remember to regenerate the index afterwards. You could also take the reverse approach and boost all other templates instead of setting low boost values. Standard values boost all items based on a data template. This may be something you want to add to your release checklist so that by default your clients are getting the most relevant content to them.

4. Rules-Based Item Boosting

You can use the rules engine to affect the boost value of each item. First, define some boosting rules under the /sitecore/system/Settings/Indexing and Search/Boosting Rules/Item Rules item. Then, to apply boosting rules to an item, show the fields of the standard template, and then in the Indexing section, define boosting rules in the Boosting Rules field.

5. Global Rules-Based Item Boosting

You can use the rules engine to affect boosting values for items. For example, you may want to boost items created or modified recently. This could be relevant to CMS users looking for content they or someone else recently contributed as well as to users in the published environment looking for the latest content. Define global rules under the /sitecore/system/Settings/Indexing and Search/Boosting Rules/Global Rules item.

6. Query-Time Boosting

You can use query time boosts to control the contents and ranking results of individual queries at runtime. The context of the user invoking the query provides information not available when compiling the index, providing for much greater opportunities for dynamic interaction. For example, whether or not the index boost a specific field, you can amplify, reduce, or otherwise affect the boosting value for that field when invoking search queries. You could even use information from DMS, such as boosting based on location, visit number, persona, purchase history, or otherwise. Query-Time boosting is currently only available in the LINQ layer therefore it has to be built in by developers.

Conclusion

Remember that boosting is not a static facility, but can work as part of your content strategy. Apply changes over time as appropriate. Remember that the more rules you have in place the longer it will take to re-index your content.

Resources

  • At Sitecore 7.0 rev. 130424 scenario described in 1. Field Boosting does not work. Sitecore ignores these values at all. Moreover, field boosting works with the only scenario: items based on different templates should contain the same named field (with different boosting values that can be set to field items directly under /sitecore/templates) and additionally items themselves must contain the same non-empty boost value.

  • The default ordering is using the following algorithm for Lucene.  score(q,d)   =   coord(q,d)  ·  queryNorm(q)  · ∑ ( tf(t in d)  ·  idf(t)2  ·  t.getBoost() ·  norm(t,d) )  If you wanted something like this you could store the term vectors, use GetResults() and get access to the Document from there. You could also store the term frequency in a computed field if that is easier for you to work with.

  • Is there a way to boost a list of items that has specific tag in its semantics field?Let say I have 5 tags in tag repository. The tag list show as links with query string attached (Tag item id), once someone click one of those tag links, I'll get that tag item from the id and then search all items, boost the item that has that tag. is it possible to do that?  searchContext.GetQueryable<SearchResultItem>().Filter( i => i.TemplateId == TemplateId || i.Semantics.contains(TagId).Boost(3f) )

  • @Novan - Your best opportunity to get this working is to use the boosting Pipelines in the ContentSearch config files. The pipeline will give you access to the IIndexable i.e. SitecoreIndexableItem i.e. Item. From here you can look at the field value of the __semantics field and then if it is your tag then boost it.

  • Hi Tim, thanks for your help. I've solved this issue by boost the value inside predicate.  foreach (var tagId in selectedTagIds) {     predicate = predicate.And( i => i.TemplateId == TemplateId );     var tempTagId = tagId;     predicate = predicate.Or(i => i.InterestTags == tempTagId.Boost(10f)); }  Cheers! :)

  • Here is one approach:  www.sitecore.net/.../Sitecore-7-Boosting-Updated-Items-with-a-resolveItemBoost-Pipeline-Processor.aspx  Unrelated, but in 7.2 I find the global boost rules here:  /sitecore/system/Settings/Rules/Indexing and Search/Global Rules