Monday, March 18, 2013

SharePoint 2013 Search: Managed Property Added to Display Template Doesn't Appear

The Search Display Templates in SharePoint 2013 provide a nice and easy way to modify how search results appear to the end user. This may involve adding additional managed properties to the mark-up such that the display template shows additional fields of search data.

However, just adding the managed property to the display template does not automatically bring it into the search results. After making changes to your display template, you may need to update the corresponding result type. This is an easy process.

Go to your site collection settings and under Site Collection Administration click on Search Result Types:

 
On the Manage Result Types page, you'll see a Property Sync message:


This is easily overlooked as it appears similiar to the health analyzer message. Simply click the Update link in the message box. The result types are updated with your display template changes:



Your new managed properties should now flow through into the search results!
 

32 comments:

  1. This is super helpful. Thank you. Would be even better if you linked to info on how to add the managed properties to the display template.

    ReplyDelete
    Replies
    1. Here ya go: http://stevemannspath.blogspot.com/2013/05/sharepoint-2013-search-adding-managed.html


      Delete
    2. Updated post with the link too!

      Thanks!

      -=Steve

      Delete
  2. Hello Steve,
    Thank you for the tip. It seems I could use it: some of my managed properties are displayed with my Display Template...others do not ! (I'm using "Use result types to display items" option)
    The problem is: I don't see any yellow bar with a link to synchronize the Result Types.
    Any idea how I can force the synchro with the bar ?
    Tried all I knew: publishing Display Templates, full sync of search, created custom result types, even iisreset and reboot (kind of overkill) but I end up with no solution...
    Thanks a lot for your help.
    Patrick

    ReplyDelete
    Replies
    1. When you save your display template, do you see the .js file updated? Are you looking at the correct Manage Result Types page? There is one under the Site Collection Administration section and one under the Search section when looking at the Site Settings.

      Delete
    2. That was it: I was looking at the wrong page. I kept checking the Site Collection page whereas I should have checked my search site Result Types page.
      But then I'm confused: what is the need for a site collection Result Type page if it doesn't override the site Result Types ?
      Thanks a lot for your quick help.
      Patrick

      Delete
    3. I typically work at the site collection level and perform all of my configurations there since I am using a Search Center. You can think of the site level configurations as an isolation level such that those items only pertain to the site.

      I may use site-level items when I implement several search results in other areas of our intranet that are contained within a sub-site of a different site collection (not within the Search Center site collection).

      Delete
  3. Hi Steve,

    I have created the new display template, the result type and made the update just like your instructions. If I come to my page and update the results web part to "Use a single template to display items"and select my template, that works like a charm. It wasn't doing it before I updated the result type.

    However, if I select "Use result type to display items" it doesn't work. My first taught is that my custom result type is not overriding the default one, which is supposed to, or at least that's what SharePoint says ( "This result type is reserved for use by the search service. To make changes, override this result type by creating a copy." )

    Second taught is that I am trying to override the wrong result type. The results that I want to modify come from a SharePoint list, so naturally I created a copy of SharePoint list, however I hover the result, the "hover panel" under the title says "Web page" so I tried to override this one too, but still no Manged property being displayed.

    What am I doing wrong!???

    ReplyDelete
    Replies
    1. Your custom Result Type is using your custom Display Template, correct? I would also set the system result type to Inactive just to be sure.

      Delete
    2. What if you'd like to override the default SharePoint templates? I found that the option above isn't available when I go into Manage Result Types and I still can't get my custom managed property. We're trying to build out a farm-wide "Expired" tag that will trigger a style change if the item is expired. In order to get this look EVERYWHERE, we need to change the OOTB display templates for the default search pages. We can't figure out why this property isn't available to us when we add it to Item_Word.html. Does the property need to be searchable? It's queryable and comes back with the REST API so we thought that was good enough...

      Delete
    3. It should be also set as Retrievable. You have Expired associated to your documents, correct?

      Delete
    4. Yes. I can bring back new managed properties for custom Result Types, but not for OOTB ones. Is this by design?

      Delete
    5. No you should be able to get it back as long as it's associated to the document. Check which crawled properties are linked to Expired. Maybe there are other expired crawled properties that aren't linked.

      Delete
  4. Thanks a lot,

    You are right, I set the "Which source should results match?" to all sources and it work perfect..

    Thanks a lot.

    ta

    ReplyDelete
  5. Hi Steve,

    Thanks for this tip, but the message to update the Managed Properties did not show!

    I am using the Site Collection context, but I don't have the search center configured. Just the site search.

    In my case, I am trying to show the file name of word documents with the managed property "Filename"

    Regards,
    Marcos

    ReplyDelete
  6. I had to reset search index and do full crawl before this option appeared in the Search Results Types and then custom ctx property worked.

    ReplyDelete
  7. Fantastic article as this isn't something we can do with a bit of PowerShell ( yet)
    I have cloned the people_item to include phone number and email then changed the People Search Web part to use the new Display template .. All good.
    Now I want to add some managed properties which I would like to display against each user ... Made similar changes to display template
    Go in to Search Results Types of my /SearchCenter site collection and no message

    I cloned the person result type ( which gets added to SC) and set it to point to my custom display template for local people search
    next I cloned Person and in my new Client Person I changed the display template
    - I have continuous crawl but set a Full Crawl.

    Still I am not seeing my manage properties

    ReplyDelete
    Replies
    1. If you do not see a message to update the Result Type, then usually the managed property is not understood. They are case sensitive so check that first. I also use the SharePoint 2013 Search Query Tool (free download) to investigate these types of issues. Also, make sure the .js file for the template is updated and has the same modified date as the .html template file.

      -=Steve

      Delete
    2. Thanks for your reply and the tip on the tool . I have now seen the Update message but no luck displaying my properties in people search. I will play around with the query to replicated people search. One question re the managed property (which is a term),. Looking at my user profile it is Xyx but in the search schema the property is owstaxIXyx .. I am assuming I need to use the latter...

      Delete
  8. Absolutely brilliant, thanks for finding the needle in the hay stack

    ReplyDelete
  9. Thanks! SharePoint had me up the wall as I tried to figure out where in the world it was caching the properties.

    ReplyDelete
    Replies
    1. Awesome! Yeah SharePoint drives me nuts :).

      Delete
    2. Awesome! Yeah SharePoint drives me nuts :).

      Delete
  10. Hi Steve,
    I've followed your instructions to add some custom metadata properties to a display template (Item_PDF). The ones I have added were already available as Managed properties and had the relevant mapped crawled properties. I don't get the option to "Synchronize with result types" - either in the site collection or search result type area. I am editing the display template by checking the file out of the display template gallery and opening it in Notepad++, saving the changes and then checking it back into the display template gallery and approving the file. The .js file has same modified date as the html one I have edited. I am logged in as the Sharepoint farm administrator. Any ideas what I might be dong wrong?

    ReplyDelete
    Replies
    1. I use SharePoint Designer and it usually works. Try adding another managed property to the tag. Also, make sure the tag is all on one line.

      Delete
    2. I use SharePoint Designer and it usually works. Try adding another managed property to the tag. Also, make sure the tag is all on one line.

      Delete
    3. I got it working by going into the Search Result Types and creating a copy of a type (in my case the PDF Type) and then I got the property sync message.

      Delete
  11. Hi Steve
    Great article that's still providing help all these years later. I would like to use Word's metadata Title to be displayed as the search result link. However SharePoint insists on providing the H1 or H2 out of the document as the search result. How can I change this. It is driving me crazy.

    ReplyDelete

Matched Content