Customizing Search Refiners in SharePoint 2010

Search RefinersI wanted to add some custom refiners to each of the custom search result pages I’ve been working on in a project. The steps to do this aren’t complex, but since I needed to read a bunch of posts out there to get it just right, I figured I’d write it up.

Create Custom Managed Properties

Only Managed Properties are available for use as refiners. While Site Columns automatically become Crawled Properties, they must be added as Managed Properties to use them as refiners (or in scopes, etc.).

To do this, we go to Central Administration -> Application Management -> Manage Service Applications -> Search Service Application -> Metadata Properties and whatever new Managed Properties we need.

Note that we cannot use the existing ContentType Managed Property in the refiners. If we do, we get the error

Property doesn’t exist or is used in a manner inconsistent with schema settings.

In order to use the Content Type as a refiner, we must create our own Managed Property which mirrors the existing one. I created a new Managed Property called ContentTypeRefiner and mapped it to ows_ContentType(Text).

Perform a Full Crawl

After creating the Custom Managed Properties, we must do a full crawl so that the new Managed Properties will be in the active index.

To do this, we go to Central Administration -> Application Management -> Manage Service Applications -> Search Service Application [you may have named this differently when you created it] -> Content Sources. From the dropdown for the relevant Search Scope, choose Start Full Crawl.

A full crawl can take a significant amount of time depending on the amount of content you may have, so it’s best to create all of the new Managed Properties before kicking one off.

Add Managed Properties into Refiners

To add the new Managed Properties as refiners in the custom search results pages, we do the following:

  • Navigate to the search results page
  • Go into Edit Mode
  • In the Refinement Panel (left side of the page) select Edit Web Part
  • In the Tool Pane, under the Refinement section, edit the Filter Category Definition XML to include the new refiners
  • Uncheck the Use Default Configuration box, otherwise your changes will disappear!

Note that any of the existing refiners can be removed. The order in which the refiners are included in the Filter Category Definition determines the order in which the refiners are shown, if there is enough content which contains that refiner’s metadata.

Here’s an example of what the XML for your own refiners might look like. This is the XML I added for the ContentTypeRefiner Managed Property. Most of the attributes are pretty self-explanatory.

<Category Title="Content Type"
  Description="Type of resource"
  MoreLinkText="show more"
  LessLinkText="show fewer" />

Useful Reference Links

Finding the SharePoint 2007 / 2010 Thesaurus Files

If you go to TechNet to find out where the thesaurus files for search are so that you can add in your own synonyms, you may be as confused as I was earlier today. It only took me about 20 minutes to figure out, but if three or four people find this post, we’ll have saved enough time for lunch.

The TechNet article you want is Manage thesaurus files (SharePoint Server 2010), though the one for SharePoint 2007 (Edit a thesaurus file (Office SharePoint Server)) is pretty much identical.

In the article, it says

By default, SharePoint Server 2010 installs the thesaurus files for all supported languages at %ProgramFiles%\Microsoft Office Servers\14.0\Data\Office Server\Config. When a search administrator creates a Search service application, the search system automatically copies the thesaurus files from the installation location (including any thesaurus files there that an administrator has edited) to %ProgramFiles%\Microsoft Office Servers\14.0\Data\Office Server\Applications\GUID-query-0\Config, where GUID is the GUID of the new Search service application. The search system performs the same operation on every query server that is running the new Search service application. Thus there is a copy of each thesaurus file on each query server that is running that Search service application.

When I looked in %ProgramFiles%\Microsoft Office Servers\14.0\Data\Office Server\Config, well, there was no %ProgramFiles%\Microsoft Office Servers\14.0\Data\Office Server\Config. Instead, because my client had decided to change the location of the index to another drive, I have to figure out where that actually was. Here’s the trick.

In complex farms, you may have multiple Search Service Application, multiple indices, etc. but these steps should work in most cases.

  • In Central Administration, go to the Search Application -> Central Administration/ Manage service applications / Search Service Application (or whatever you called it)
  • At the bottom of the page, you’ll see a section called ‘Search Application Topology’
  • Click the Modify button and on the next screen look for the ‘Index Partition’ (you may have more than one)
  • Click on the ‘Query Component 0’ link and Edit Properties
  • The field called ‘Location of Index’ contains the root location for the thesaurus files


Looking in that folder, you should find folders that look something like this:


As noted above, the thesaurus files you want to work with are in the GUID-query-0\Config folder. In my case above, it’s E:\Data\SearchIndex\Office Server\Applications\0f78bae4-05b9-417f-b533-43326409dfcc-query-0\Config

Happy equivalency!

One side note: it boggles my mind that there is no UI to manage synonyms in the thesaurus, but there you go.