Compartilhar via


Customising SharePoint 2010 Search Refiners

Scenario: Your documents go through a series of steps (e.g. Started, Working, Complete, Cancelled) and you have a metadata column (e.g. Process Step) that tracks the status of a particular document.  You have SharePoint Server 2010 and Enterprise Search you want users to be able to refine search results to a particular process step.

How To:   As the metadata column for tracking document status isn’t managed metadata(https://technet.microsoft.com/en-us/library/ee424403.aspx) the search crawler needs to be made aware of your particular column so that we can use it to configure search.  To this we need to create a Managed Property:

  • Central Administration -> Manage Service Applications -> Search Service Application -> Metadata Properties
  • New Managed Property -> Complete the form adding in a mapping to the ows_ crawled property for your column (e.g. ows_Process_0x0020_Step)
  • Start an re-index against the content source to crawl the data for the managed property

Now that search is aware of the column we can go ahead and use it in the search refiners.  This is done by configuring the Refinement Panel WebPart that is included on search results pages:

  • Put the results page in edit mode and edit the properties of the Refinement Panel WebPart
  • In the Refinement section -> Filter Category Definition -> Add the following to the XML definition modifying Title, Description and MappedProperty for your scenario:
 <Category Title="Process Step" 
          Description="Process Step of the document" 
          Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"
          MetadataThreshold="5"    
          NumberOfFiltersToDisplay="4"    
          MaxNumberOfFilters="20"    
          SortBy="Frequency"    
          SortByForMoreFilters="Name"    
          SortDirection="Descending"    
          SortDirectionForMoreFilters="Ascending"    
          ShowMoreLink="True"    
          MappedProperty="ProcessStep"    
          MoreLinkText="show more"    
          LessLinkText="show fewer" />
  • Uncheck the Use Default Configuration option
  • Save the web part and then the page and issue a search query to see the refiner in action

If you don’t see the refiner showing your options and you didn’t get any errors, there are a few things that will impact visibility of your custom refiner.  Firstly, you need to make sure that you have re-indexed your content to make sure that there is data for the refiner to work with.  Secondly, you need a big enough result set containing your column to make the refiner meaningful; if it’s too small the panel won’t display your refiner.  Thirdly, the refiners are shown in the order they are defined in the XML so if you place yours at the end but configure the refinement panel to only show the first X, it won’t appear in the panel.