Create a content type search refinement panel in SharePoint 2010

On a recent SharePoint 2010 project I’ve been asked to configure the search experience. There’s been no great customisation to do in this instance, however with just a little configuration it’s been possible to achieve great results (pun intended).

I’ve started from a site based on the Enterprise Search Centre template and made a few modifications such as adding a scope with a custom search results page, returning federated search results, and ensuring that the content sources are setup correctly etc.

In addition, I’ve also made use of the great new Refinement Panels that are available out of the box with the Microsoft SharePoint 2010 search experience. For great information on what these refinement panels are and how they can be configured I’d suggest heading over to the SharePoint Analyst HQ blog by Michal Pisarek.

Search Results Refinement Default

In my case we have some areas of the solution that have a well-defined set of Content Types. Out of the box there is a refinement panel for ‘Result Type’ however this is different to the content type, e.g. Word as opposed to Proposal. So the challenge was to create a new refinement panel to replace the Result Type refinement panel. Note, it was to replace in my case but there’s no reason why it can’t be in addition to.

The steps to go about this are:

  1. From central administration navigate to the search service application and create a new managed property mapped to the ows_ContentType property. I named mine ContentTypeRefinement
    1. Note, for some reason the default Content Type manage property will not work as a refiner
      [Update 31/01/2011: Michal has written another great post, which explains why this is so]
    2. Remember to kick off a full crawl after creating your managed property
  2. Edit the search results page, and modify the Refinement Panel web part
  3. In the Refinement category modify the Filter Category Definition to include the following XML:
<Category Title="Content Type"
 Description="The content type of the item"
 Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"
 MetadataThreshold="5"
 NumberOfFiltersToDisplay="4"
 MaxNumberOfFilters="0"
 SortBy="Frequency"
 SortDirection="Descending"
 SortByForMoreFilters="Name"
 SortDirectionForMoreFilters="Ascending"
 ShowMoreLink="True"
 MappedProperty="ContentTypeRefinement"
 MoreLinkText="show more"
 LessLinkText="show fewer"/>

Saving the page you should now see a refinement panel for Content Types:

Search Results Refinement Conent Type

Fantastic! But wait, there’s more. If you are using content types throughout your site and have a well-structured taxonomy it’s possible that you’ll want to group the options in the refinement panel to reflect, say, similar content types. This can be done by editing the XML to associate values with a particular refinement as per the below example:

<Category Title="Content Type"
 Description="The content type of the item"
 Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"
 MetadataThreshold="5"
 NumberOfFiltersToDisplay="4"
 MaxNumberOfFilters="0"
 SortBy="Frequency"
 SortDirection="Descending"
 SortByForMoreFilters="Name"
 SortDirectionForMoreFilters="Ascending"
 ShowMoreLink="True"
 MappedProperty="ContentTypeRefinement"
 MoreLinkText="show more"
 LessLinkText="show fewer">
 <CustomFilters MappingType="ValueMapping" DataType="String" ValueReference="Absolute" ShowAllInMore="False">
  <CustomFilter CustomValue="Invoice">
   <OriginalValue>Invoice</OriginalValue>
  </CustomFilter>
  <CustomFilter CustomValue="Project Document">
   <OriginalValue>Proposal</OriginalValue>
   <OriginalValue>Specification</OriginalValue>
  </CustomFilter>
 </CustomFilters>
</Category>

From the screenshots in this post you can see that we’ve taken the out of the box refinement panel and customised it through several stages to provide a solution specific refinement panel.

Search Results Refinement Conent Type Configured

share and enjoy
  • Print
  • Twitter
  • Digg
  • del.icio.us
  • StumbleUpon
  • Yahoo! Buzz
  • Google Bookmarks
  • Facebook

39 comments to Create a content type search refinement panel in SharePoint 2010

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>