Explain rank in Sharepoint 2013 Search
January 25, 2013 20 Comments
Default ranking model in Sharepoint 2013 is completely different from what we’ve seen in FS4SP and is definitely a step forward comparing to SP2010. In a nutshell it uses multiple features (to take into account query terms, it’s proximity; document click-through, authority, anchor text, url depth etc ) which are mixed with help of neural network as a final step. Details can be found in patent claim http://www.google.com/patents/US8296292.
Hopefully there’s a way to bring more light into this black magic. I’ve modified default Display Template and added “Explain Rank” link to each item. This link redirects user to ExplainRank page which hosted under {search_center_url}/_layouts/15/ folder.
I used
- d=ctx.CurrentItem.Path
- q=ctx.DataProvider.$2_3.k (have found this hidden property using trial & error method)
- another option is to extract value for q= from QueryText from ctx.ListData.Properties.SerializedQuery which value was<Query Culture=”en-US” EnableStemming=”True” EnablePhonetic=”False” EnableNicknames=”False” IgnoreAllNoiseQuery=”True” SummaryLength=”180″ MaxSnippetLength=”180″ DesiredSnippetLength=”90″ KeywordInclusion=”0″ QueryText=”star wars” QueryTemplate=”{searchboxquery}” TrimDuplicates=”True” Site=”1436c4c3-34b4-4e32-bd41-4d28fc0f1435″ Web=”5291616c-f750-45db-9e3b-68c7c2e82b9f” KeywordType=”True” HiddenConstraints=”” />”)
var explainHtml = String.format('<a href="/_layouts/15/ExplainRank.aspx?q={0}&d={1}" title="Explain">Explain Rank</a>', ctx.DataProvider.$2_3.k, ctx.CurrentItem.Path);
(upd: here’s a link to complete display template http://pastebin.com/SfbFj9yG)
ExplainRank.aspx page essentially performs following actions:
- Prepares KeywordQuery with values specified in URL (query, item url, + a number of configuration parameters that exist in SerializedQuery but were omitted in this demo for the sake of simplicity)
- Specifies to retrieve ranklog property.
- Executes query
- Parsers ranklog with help of RankLogParser (Microsoft.Office.Server.Search.Administration)
- Renders features/scores using controls derived from RenderableRankingFeature (Microsoft.Office.Server.Search.WebControls)
As a results you are able to review detailed explanation on rank log calculation and have a better understanding why a given document scored with specific rank.
Even if you’re not familiar with advanced information retrieval ranking models, you will easily locate in which properties there were hits, which features contributed to final score.
This is only the beginning of our journey into ranking and relevancy tuning of SharePoint 2013 Search. Stay tuned, in next chapters we will dive more deep.
Reblogged this on Sergey Tihon's Blog and commented:
Add your thoughts here… (optional)
Can you post the entire value of the explainHtml variable ? I am having difficulty getting the value of QueryText.
Thank you,
I’ve updated the post with a codeblock containing explainHtml variable. I ended up using ctx.DataProvider.$2_3.k variable, instead of non-trivial xml parsing from QueryText. Hope this helps.
The entire display tempalte is here http://pastebin.com/SfbFj9yG.
Very nice find and very useful.
Pingback: How SharePoint 2013 Ranking models work | Insights into search black magic
I’m getting a 403 forbidden trying to display the explainrank.aspx page. I’m accessing the page as a site collection owner and farm administrator. Any ideas?
Got it.. Finally able to get in using the SP Farm Account
You’re welcome! 🙂
Hi Darrin,
long time no see. If you want to follow the least privilege route, then you can make the user administrators of the search service Application instead. You need full Control permissions for it to work. This also matters for using rankdetail in selectproperties
The ExplainRank.aspx page doesn’t work for BDC search results.
Complete URL:
http://spv15-dev-web01/_layouts/15/ExplainRank.aspx?q=tool&d=bdc3://fastenal_vendors_fastenal_vendors/Default/00000000%252D0000%252D0000%252D0000%252D000000000000/4495/Fastenal%2520Vendors/5089?s_id=injUAAA==&s_ce=04081020800080g102000400g000f7
It says: “Error parsing ranklog XML: Requested document not returned in the query.”
I guess is because of the URL of this bdc3://xxxxx
Then, how to get it work for BDC search results?
oh maybe I just need to create profile page for BDC external content type and recrawl it. I am trying it.
Problem resolved.
Pingback: Neural networks in Visual Studio and SharePoint Search | Insights into search black magic
aside from ‘d’ and ‘q’, are there other parameters that we can use for the explainrank.aspx page? for example, i want to use other rankingmodelid, is it possible to pass the guid to this page?
Pingback: Sharepoint 2013 Search Ranking and Relevancy Part 1: Let’s compare to FS14 | Search Unleashed
Alexey,
Great post, just discovered it yesterday during a search session given by Joris Poelmans. The only thing that my eye fell on was that you use a hidden property $2_3. You could also retrieve the query text with methods like this:
Thanks for the share.
Regards,
Elio
Pingback: Search Query Tool v2–released on Codeplex | TechPour.com
Pingback: Katpro Technologies Pvt Ltd | JOPX on SharePoint, Big Data and the future of business!!!!!!
Pingback: Katpro Technologies Pvt Ltd | JOPX on SharePoint, Big Data and the future of business!!!!!
Reblogged this on madhavan.