Posted by: R Manimaran | November 4, 2014

SharePoint 2010 Creating Custom Ranking Model – with Example –Part 1

SharePoint 2010 Creating Custom Ranking Model – with Example –Part 1

SharePoint Enterprise Search using the Ranking Model called BM25 algorithm.  This ranking models uses the field weightage on the managed properties. By default below are the built-in ranking models available in the SharePoint 2010 Search. We cannot modify these existing ranking models instead we can create my ranking model and attach.

Ranking Models

Let us jump in to an example.

I have a custom site column “EmpName” which is mapped with a Document Content Type “Employees”. This Content type is associated with the Document Library. For each employees we will have a supporting document associated with him along with the other metadata fields like EmpID, DOB, DOJ and Work Location. The Employee name will be placed in the document associated to the user. And also a particular employee name will be mentioned in other user document as Reporting to/Reporters. So when I do a Keyword Search using the Employee name SharePoint will not bring the exact Employee record first (i…e based on EmpName metadata) instead it bring based on the name placed inside the document.

This is because my search using the default ranking model “MainResultsDefaultRankingModel” in which the weightage is given to body,title,Author respectively. Here my custom column EmpName is not there so when I did a Search I get the results as below.

Results1

Let us create a new Ranking model to fix this. Before that I have created the below.

  1. Created site columns and associated to a Document Content type “Employees”
  2. Associate the Employees content type to a document library.
  3. Added some sample documents with metadata values.
  4. Initiate the Full Crawl in the Search Service application
  5. Created the Managed Property for the Site Columns crawl property.

Content Type:

EmployeesContentType

Document Library:

DocumentLibrary

Custom Ranking Model Schema: Custom Ranking Model has a XML Schema where we need to specify the custom managed Property along with the weight-age. We can find the syntax here

Below is my Custom Ranking Model Example.

RankingModel

Here in the XML we need to specify the PID number of the managed property. This can be identified using the below PowerShell.

pidvalue

Next step is we need to upload the new ranking model to SharePoint. I have placed my xml file in my local drive and used the below PowerShell command to create a new Ranking model.


$rankingModel=Get-Content C:\Maran\EmpRankingModel.xml

$rankingModel=[string]$rankingModel

$ssa = Get-SPEnterpriseSearchServiceApplication -Identity "Search Service Application"

New-SPEnterpriseSearchRankingModel -SearchApplication $ssa -RankingModelXML $rankingModel

We can check our new Ranking model added to the SharePoint using the below query.

CustomRanking

In the part 2 we will use the Keyword query to get the results.

References:

http://technet.microsoft.com/en-us/library/ff607980.aspx

http://msdn.microsoft.com/en-us/library/ee558793%20(office.14).aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: