Based on some feedback from a previous post, a reader commented that it would be nice to see how to add managed properties to a search display template. The most common method is a one-to-one mapping, however, you may link a search result item property to multiple managed properties. This post explains both methods.
While the recommended approach is to use Design Manager to upload display templates, I find it much easier to make copies and modifications using SharePoint Designer 2013. You may access the search display templates from SharePoint Designer 2013 using the method explained in this post.
One-to-One Mapping
Each Search display template contains default managed properties. They appear in the <mso:ManagedPropertyMapping> tag at the top of each template:
Sometimes when making copies of the templates or modifying existing ones, the quotes become http encoded:
It doesn't matter as either way will work. The syntax for one-to-one mapping is as follows:
While the recommended approach is to use Design Manager to upload display templates, I find it much easier to make copies and modifications using SharePoint Designer 2013. You may access the search display templates from SharePoint Designer 2013 using the method explained in this post.
One-to-One Mapping
Each Search display template contains default managed properties. They appear in the <mso:ManagedPropertyMapping> tag at the top of each template:
![]() |
{Click on image to see larger view} |
![]() |
{Click on image to see larger view}
|
'<<property name to be used in current item>>':'<<managed property name>>'
To add a new managed property, simply add another entry. For example, if I had a managed property named "CustomerID", I would add 'CustomerID':'CustomerID', to the <mso:ManagedPropertyMapping> tag:
For maintainability it is recommended to name the current item property name the same as the managed property name. Once that is added, you may now use the new property by referencing it from the current result item:
ctx.CurrentItem.CustomerID
Once you save your changes, you need to update your result type such that the query component knows which properties need to be returned for the search result.
One-to-Many Mapping
If you take a look at the Item_Video_CompactHorizontal.html template, you'll notice that they are mapping a search result item property to multiple managed properties:
![]() |
{Click on image to see larger view} |
The syntax here is a little different:
'<<search result item property name>>'{search result item property name}:'<<list of managed properties>>'
The list of managed properties are separated by semicolons. I am assuming that the value of the search result item is populated with the first managed property that has a value based on the order listed.
To use the managed property value within the template code/mark-up, you must get the value from the context:
var imageURL = $getItemValue(ctx, "Picture URL");