Customizing Search Results (SharePoint 2010): People Search Results Custom Sorting using XSLT

Overview

By default People Search Results web part sorting capabilities are limited by the following options:

  • Relevance (default)
  • Social Distance
  • Name

Below is presented XSLT based approach how to provide additional sorting options for People Search Results web part.

But before we proceed let me clarify the main limitation of this solution:

  • the specified method allows to sort  search results returned for page only (to control results returned for page ResultsPerPage property is used)
  • applying sorting take place during XSLT transformation (in our case it  is applied to relevant results)

Solution description

Provide custom sorting options values

ParameterBindings property is used for storing custom sort options values and passing them to XSLT:

,where

CustomNameSortLabels and CustomNameSortValues   are used for storing  custom sort option labels and values respectively.

Customize Sort Options  in People Search Results

In order to display custom sort options the following XSLT template is used:

Complete XSLT file for People Search Results  could be found here

Below is shown sorting options control after applying specified XSLT and providing Parameter Binding property value from above example

SortOptions

Sorting for search results is defined using XSLT sorting element:

Complete XSLT file for People Search Results with custom Sort Options could be found here

Results

People Search Result page with results sorted by Last Name is shown below

PeopleSearchResultsCustomSort

References

Advertisements

9 thoughts on “Customizing Search Results (SharePoint 2010): People Search Results Custom Sorting using XSLT

  1. Thank you Vadim. I got this working by including the XSLT code and Parameters in both the web parts (Search Action Links and Core Results for People)… As you have specified in your blog post, only the current page items are getting sorted. One issue is, once sorted in custom property, it is appending a query string to the URL and is not getting cleared. Hence the OOB sorting (Default, Name, Social Distance) are not working.. I can write some script to clear it though…

    • Hi Srikanth,
      regrading sorted results per page only, unfortunately using only XSLT based approach it seems that this is the only way.
      Thank you for pointing on issue with not clearing custom property, may be you will provide me with the fixes
      P.S. In next post will be discussed another way about sorting search results.

  2. Hello many Thanks for your Blog Entry.

    Can i change the Display Value “Last Name” to “Name”?

    Is this possible?

    Thanks for your Answer.

    Michael

  3. Hi,
    I applied your code (thanks!) but got error when selecting a custom sortby column. “Internal server error exception: System.Xml.XmlException: Unexpected end of file has occurred. The following elements are not closed: Columns, root. Line 1, position 162. ”
    Also how to hide “default” and “social distance” options?
    Thanks, and sorry, I am not a xslt person or developer.

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