Understanding item ranking in SharePoint 2013 Search
In SharePoint 2013 it’s more important than ever before to understand item ranking in search results.
An enterprise-class search engine
One of the great investment areas in SharePoint 2013 is search. Merged with the enterprise-class Fast engine SharePoint 2013 Search is no longer the thing that you go to when you search for a document once in a while. In search-driven publishing scenarios SharePoint 2013 Search drives the content publishing process.
Publishing content with SharePoint 2013 Search
Search-driven content publishing introduces new capabilities to web publishing. It allows you to publish content dynamically using concepts such as relevance and content targeting. If you have worked with publishing in SharePoint in the past, but are new to SharePoint 2013 search-driven publishing, it can be sometimes surprising why certain content is displayed to users. Understanding how SharePoint ranks content can help you improve relevance for your content.
SharePoint 2013 Search uses complex language processing rules, analytics and ranking models to find the most relevant content. Luckily it offers us some aids to help us understand the ranking of particular piece of content.
Understanding item ranking in SharePoint 2013 Search
SharePoint 2013 Search allows you to peek into the result of its ranking model by retrieving the rankdetail Managed Property. This property contains all the different pieces that add up to the total ranking of the specific search result.
Important: You can retrieve rankdetail for the results of every query as long as the total number of result is less than 100. If there are more results the rankdetail property will be empty.
Although very detailed, it’s pretty hard to understand the contents of the rankdetail Managed Property. To help us, SharePoint 2013 has the ExplainRank.aspx page which is a truly hidden gem, that displays the rankdetail for a single item in a more comprehensible way.
The Explain Rank page requires two query string parameters:
- q – which contains the query
- d – which specifies the path of the item for which you want to see rankdetail
For example:
https://authoring.mavention.nl.local/_layouts/15/ExplainRank.aspx?q='waldek mvp'&d=https://authoring.mavention.nl.local/nl-nl/Pages/waldek-mastykarz.aspx
Both parameters are then put in the following search keyword query:
[value of the q parameter] Item="[value of the d parameter]"
Optionally you can pass the following query string parameters to control the search query:
- keywordinclusion – can be set to any or all (default). Should the search result contain all or any of the specified search terms
- enablephonetic – should phonetic forms be used to find matches
- enablenicknames – should the exact terms or nicknames be used in search
- enablestemming – should stemming be enabled
- sourceid – ID of the result source to use
- lang – name of the locale to use for the query, ie. en-US
For the enablephonetic, enablenicknames and enablestemming query string parameters it doesn’t matter what their value is. The Explain Rank page only checks if the query string parameters are set or not.
Although the ExplainRank.aspx simplifies understanding rankdetail there is one catch when using it.
Inconvenient ExplainRank.aspx and catalog items URL rewriting
When parsing the rankdetail contents the ExplainRank.aspx page tries to retrieve the result item from the result table using its path (as specified using the d query string parameter). Unfortunately, when working with catalog items which use URL rewriting, the Path Managed Property is rewritten what causes the ExplainRank.aspx page to fail with the following error:
Error parsing ranklog XML: Requested document not returned in the query.
An easy fix would it be for the ExplainRank.aspx page to use the OriginalPath Managed Property instead. Unfortunately the ExplainRank.aspx page is not extensible and it uses non-public API to make things even worse.
Luckily there is a way to view the rankdetail information for catalog items in a comprehensible way.
Viewing rankdetail for catalog items with Mavention Explain Rank
Mavention Explain Rank is a SharePoint 2013 Farm solution which contains almost an exact copy of the standard ExplainRank.aspx page with one difference: it uses the OriginalPath Managed Property to retrieve the item for which rankdetail should be displayed.
Mavention Explain Rank is a quick fix for the lack of support for browsing rankdetail for catalog items with URL rewriting. As a result Mavention Explain Rank heavily relies on reflection to access all of the internal APIs used by the original ExplainRank.aspx page. It’s not an optimal solution but it just work and it might help you understand the ranking of your catalog items.
Summary
As SharePoint 2013 Search is used in more solutions it’s essential to understand the ranking of search results when building search-driven solutions. Using the standard ExplainRank.aspx page can help you read the contents of the rankdetail Managed Property that contains the details on how a particular item has been ranked. Unfortunately the standard ExplainRank.aspx page doesn’t support displaying rank details for catalog items with URL rewriting. Using the Mavention Explain Rank solution instead of the standard ExplainRank.aspx page you can view the rank detail information in a comprehensible way.
Download: Mavention Explain Rank (9KB, WSP)