User Context Sensitive Searching In SharePoint 2013 Part 1

The purpose of this two part series is to demonstrate how you can alter SharePoint 2013 search results based upon the current user.  The example I’ll use here is promoting specific search results to the top of the search result list based on the user’s department in Active Directory.  This feature is known as User Segmentation and the method I describe is my take on the information and code available here http://blogs.technet.com/b/speschka/archive/2012/12/02/using-user-context-aka-as-segmentation-in-search-with-sharepoint-2013.aspx and here http://msdn.microsoft.com/en-us/library/jj870831.aspx

In order for this to work you need SharePoint 2013 Enterprise, as the code makes use of the Content Search Web Part (CSWP), which is only available in SharePoint 2013 Enterprise.  You need to have an instance of the User Profile Service Application working with users imported from Active Directory and the department field populated.  You also need to have configured the Managed Metadata Service Service Application as we make use of the people taxonomy.  You’ll also need Visual Studio 2012 with the Office Developer Tools for Visual Studio 2012 (http://aka.ms/OfficeDevToolsForVS2012) to edit the web part.

An overview of the method I’ll cover in the two posts is as follows:

Create a web part which is an extension of the CSWP.  The web part retrieves the current user’s department from the User Profile Service Application within SharePoint.  Next the web part looks up the term ID of the user’s department within the People taxonomy in the Managed Metadata Service.  The department tag ID is added to the User Segment terms.

A query rule is created within the Search Service Application which fires for a specific department in the User Segment terms.  The query rule is used to alter the search result ranking.

The Visual Studio solution is available to download here https://1drv.ms/u/s!AnQuhI0KfyfurTYC0BlSPffu1r_I You can open the solution in Visual Studio and deploy it, or just deploy the wsp file from Search User Segmentation\Search User Segmentation\bin\Debug folder within the zip file using PowerShell, or STSADM.

Advertisements

3 thoughts on “User Context Sensitive Searching In SharePoint 2013 Part 1

  1. Pingback: SharePoint 2013 : Recherche – Présentation du contexte utilisateur (User Segmentation) | SharePoint by Benoît Jester (Asipe)

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