Friday, January 9, 2015

How to: Boost metadata in SharePoint search results

As pointed out by Mike Fairly in the TechNet forums (see thread), the default rank profile, or any other rank profile included with SharePoint, does not give any weight in particular to tagged content.

This means that if you add managed metadata columns or Enterprise Keywords to a list or library, the terms used will merely help on content recall, but not provide any extra rank to the items moving them higher up in the search results.

On the other hand, when promoting the use of tagging to information workers, you might think they want a return on investment for those tags, meaning tagged items should appear higher in the result set.

There are several ways to go about fixing this:

  1. Create a custom rank profile
  2. Change the weight of managed properties
  3. Use dynamic ranking via the XRANK operator

The easiest in terms of implementation and flexibility is #2.

You may download working search configuration files to apply the tag boost from https://github.com/wobba/SearchConfiguration.

Without going too much into detail of the default rank profile, the part we are after is the BM25F (Best Match 25 Fielded) part of the rank profile. This part says something about how much weight should terms get if they appear in specific fields. This means that hits in a title should count more than a hit in the body text of a document.

A simplified listing provided by Igor Veytskin@MSFT, ranks the included fields in the default rank model ordered by relevant importance to each other:

  • Title                            100%
  • QLogClickedText     72%
  • SocialTag                    59%
  • Filename                     52%
  • Author                         41%
  • AnchorText               18%
  • Body                                7%

If you look at the search schema for each of the managed properties listed, you see they are mapped to different weight groups (Search Schema –> pick managed property –> Advanced Searchable Settings). For example Title is mapped to Context 1.

image

Important: The number in the context level does not correspond to importance and higher ranking. It’s merely a lookup number.

The levels are assigned as follows:

  • Title                                    1
  • QLogClickedText          3
  • SocialTag                       14
  • Filename                          2
  • Author                              5
  • AnchorText                    6
  • Body                                  7

By default tags (or any custom column) will be assigned to Context 0, and thus ranked even lower than the body content of a document, as it’s not ranked at all.

And now comes the hard part. By association, any managed property set to use the same weight group as any of the above managed properties will get the weight from that managed property when searching.

If you for example assign a managed property MyFooBar to Context 1, then search matches in that property will get boosted the same as titles. If you want less boost, use one of the other weight groups.  And that’s all there is to it – from a technical point of view. Also, the managed property you want extra rank on HAS TO BE MARKED AS SEARCHABLE. If not you won’t get the extra rank you are looking for.

image

The actual implementation

If you are using site columns in your libraries and lists and want to boost search hits in managed metadata columns or tags, then you can edit the automatically created managed properties for that column (named owstaxIdColumnName) and change the weight group. This works as automatic managed properties for managed metadata columns are marked searchable by default.

If you want to boost content in all managed metadata columns, regardless of where it’s used and the name, you have to perform the following steps:

  1. Create a new managed property on the SSA/tenant level and name it TagBoost
  2. Check the Searchable box
  3. Map the crawled property ows_taxId_MetadataAllTagsInfo to your new managed property
  4. Trigger re-crawl of your content

image

Note: There is an existing managed property named owstaxidmetadataalltagsinfo, but this property is not marked as searchable, thus changing the weight group has no effect. I don’t like to mess too much with existing managed properties, and thus opt to create a new one.

As an example picture a list item with the following columns and values.

Column Value
Title List test
Enterprise Keywords
(managed meta data)
red car

Using the SharePoint 2013 Query Tool and looking at rank details, for the search red car, you get extra rank from the Title managed property – by association from the TagBoost managed property as it’s mapped to Context 1.

image

You may download working search configuration files to apply the tag boost from https://github.com/wobba/SearchConfiguration.

References:

TechNet: Influence the ranking of search results by using the search schema

MSDN: Tune your ranking model with rank features

Trigger re-indexing of content in SharePoint Online

SharePoint Sample Search Configurations