SharePoint 2013 introduced dozens of new features and updated many of the existing ones. It can be overwhelming to digest all of these changes, which often means some go unnoticed. Search faceting is one of these overlooked features. In this blog post, I will walk through the steps to create custom search facets for SharePoint 2013.
What Are Search Facets?
Search facets, or refinements, are extremely valuable in so many ways. A search facet is simply a field to filter search results by. In SharePoint, search facets show up on the left side with basic refiners such as, Author, Modified date, etc. The facet then allows you to filter the search results by the user who created the item and when the item was last updated, in a simple and fun way.
Let’s imagine I am on our Credera Project Portal, a basic SharePoint 2013 site where team members collaborate on client projects. I want to find all “overview” documents for my current project “CRM Support.” To do this, I would search “overview” against all project sites, and this is what I would get:
On the left side, I have the default search refinements. By clicking “Matt Riedel” under the Author heading, I am filtering these results to show only documents that I created. Now, I want to find documents pertaining to my “CRM Support” project, which has the URL “/CRM Support”. However, this search is giving me results for the “CRM 2013 POC” project and others.
With SharePoint 2013, custom refinements are created completely through the UI, which eliminates the need for writing any code at all. This is huge for small businesses, as you no longer need a developer to do this for you. A power user with basic training can accomplish the same goal. Follow these few easy steps to create custom search facets.
Step 1: Configure Fields for Refinement
First, we need to determine which fields we want to refine our search results by. On our project portal, every document uploaded to a project site gets tagged with metadata about the project, such as the project name, current sprint, document type, client, etc. SharePoint does not crawl these custom fields by default, so I need to configure the Search Service Application in Central Administration to crawl these fields.
Increase business process efficiency and collaboration with Microsoft SharePoint
To accomplish this, navigate to Central Administration, click “Manage service applications,” and choose your search service application to get to the Search Administration screen. On the left hand navigation, click “Search Schema” under the “Queries and Results” heading to get to the Managed Properties screen. For each list column, SharePoint creates a Managed Property which is used by the Search Service Application.
From here, you can search for the managed property you want to configure. In my case, I will search “project” to find my managed property relating to the “Project” field on my document. It can be tricky to find the exact managed property you are looking for because SharePoint adds text to the name depending on the data type of the field. Since my project field is a text field, it maps to a managed property called “ProjectOWSText”. Click on the property to configure it. Ensure that “Queryable” and “Retrievable” are checked and “Refinable” is set to “Yes – active.” Once set, your property should look like the following:
Repeat this process for any additional fields. Once all managed properties are configured, performing a full search crawl is necessary. Search will then go through all items and index these new fields.
Step 2: Modify Refinement Web Part on Search Results Page
Now that the backend of search is configured, these custom refinements need to be surfaced through a custom search page. The refinement panel is a web part that comes with the standard search results page. To show new refinements, all we need to do is modify this web part.
Let’s get started by editing the standard search results page in the default search center. On the left side you will see the Refinement web part. Click the arrow that appears next to the heading, then click “Edit Web Part.” The Refinement web part settings will appear on the right side of the screen. From here, click the “Choose Refiners…” button. A new modal window appears in the center of the screen. This is where the managed properties from step one are used. At the top, you can choose which managed properties to show and the order in which they appear. Below, you can set some additional settings, such as the display name, sorting, and template. Your web part configuration should look similar to the following:
Once the refinements have been chosen, click the “OK” button to close the modal window. In the web part properties, click “Apply,” then “OK.” Save and check in the page so others can see these new refiners also.
Searching and Enjoying
The search results page is now configured to show the custom refiners we have just created. I can now perform the same search as before, but now I can filter to show only the documents for my current project, “CRM Support”:
The Old Way
If you have ever worked with Custom Search Faceting in SharePoint 2010, you understand how difficult and tedious it was. It required the knowledge of XSL and writing XML to achieve the results. The overall process was similar in that the managed properties need to be configured for search to index these fields. However, it gets much more difficult when modifying the refinements in the Refinement web part. Rather than having a nice “Choose Refiners…” button, the old button was “Edit XSL…” Below, you can see the complexity in adding search facets to a SharePoint 2010 search page:
Now which method looks easier to you? Post your questions and comments below, or find us on Twitter at @CrederaMSFT.