This is a blog post in the series "How to change the way search results are displayed in SharePoint Server 2013." To demonstrate how you can customize your search results, I'll use examples from an internal Microsoft Search Center.
For an overview of the blog posts in this series, go to How to change the way search results are displayed in SharePoint Server 2013.
In the previous blog post, I explained how item display templates and hit highlighting work. In this blog post we'll learn:
About the Search Center example in this series
To help explain how you can customize the way search results are displayed, I’ll use examples from a tool that I use on a daily basis: an internal list of Microsoft publications.
As you know, Microsoft publishes thousands of articles across TechNet, MSDN and office.com. To assist in the publishing process, we use several SharePoint lists. Each item in a list represents an article or a media file. To make it easy to find information about a particular list item, we created a Search Center that searches across these lists.
In our first version of the Search Center, all the search results were displayed identically. This was because by default, all list items belonged to the same SharePoint List Item result type. We wanted to change this so that just by glancing at the search results, we could distinguish between an article published on TechNet and an article published on MSDN. We also wanted to add important information about each search result that would be visible without having to select and open it.
Before we did anything in SharePoint, we sat down for a planning session. The first step was to decide how we wanted to categorize our search results. We came up with the following categories:
Once we had defined the categories, we then needed to distinguish the categories from each other. Items in our list contain a site column named Distribution Channel. This site column contains the value of the platform to which an article has been published, for example TechNet Library.
We decided that we would use values from the Distribution Channel site column to distinguish the categories from each other.
With these decisions in hand, I set out to create new result types for each of the categories. The procedure for creating a new result type is identical for all categories, so to save space, I will only show you how I created the TechNet content result type.
How to copy a default item display template
Before you create a new result type, you should create a new item display template that your new result type will use. To avoid having to create a new item display template from scratch, you can copy an existing one. Try to copy an item display template that is as close as possible to the type of content you have. Here's what you should do:
In my scenario, I wanted to customize search results for SharePoint list items. From this reference table I was able to determine that the default item display template that is used by the SharePoint List Item result type is the file named Item_Default. Because I had mapped my network drive, I could easily copy the Item_Default file in Windows Explorer.
In my scenario, I changed the <title> tag to TechNet content.
Now that we have created a new item display template, we can move on to creating a new result type.
How to create a result type
Depending on your permission level, you create a result type on two levels:
To save space, I will only show you how to create a result type as a Site collection administrator.
Instead of creating a new result type from scratch, you could make your life a bit easier by copying an existing result type and modifying it to fit your new result type. If you do this, ensure that you copy a result type that closely resembles the new result type you want to create.
In my scenario, I wanted to customize search results for SharePoint list items, so I copied the SharePoint List Item result type.
This opens up a menu where you can specify the result type based on managed property values.
In my scenario, all list items contain a site column called Distribution Channel. As I showed you at the beginning of this blog, this site column contains the publication platform value, for example TechNet Library. I wanted to use values from this site column to specify which list items should belong to my new result type
Your newly created result type is now listed on the Managed Result Types page. In my scenario, I could see that the TechNet content result type had been created.
So now that we have a new result type, the next step is to modify the display template that is associated with this result type. There are different ways you can go about doing this, so in the next two blog posts, I'll explain two different options.
Next blog post in this seriesHow to display values from custom properties in search results - option 1
Additional ResourcesConfigure result sources for search in SharePoint Server 2013Result types and display templates that are used to display search results in SharePoint Server 2013