Thursday, April 24, 2014

The 100% way of getting your custom properties to show in your Display Templates

I’ve been meaning to blog this for some time, so here goes.

The issue is that you create a custom display template, and in that template you add a custom managed property which you want displayed like I have here with LinkOfficeChild.

<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>
<mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title','LinkOfficeChild':'LinkOfficeChild'</mso:ManagedPropertyMapping>
<mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded>

The next step you do is create a new Result Type, set your trigger conditions and choose to use your custom display template.

image



You are even wise to read the Note at then end, go back to the Result Types page, click the update button to get the awaited message that everything is now OK and should work.

image

Then you head over to your search page and you get NOTHING!

image

So what do you do to resolve this? Go back to the Result Source and check Optimize for frequent use.

image

…and your values will show!

image

13 comments:

  1. Mikael,
    In reference to this post, have you ever encountered a situation where you've created a custom item display template, created a result type to use this template based on any number of conditions (such as a managed property's value, the type of content, etc.), set the search results web part to use result type rules to decide which template to use, and see SP ignore your settings?

    On more than 1 occasion, I've done all of the above and the custom item template is not applied unless I set the search results web part to use a single template, which is not desirable.

    Any thoughts?

    Thanks,
    John Lenker

    ReplyDelete
    Replies
    1. Usually solved by letting the result type work for Any source....but it is a bit weird at times for sure.

      Delete
  2. Hi MIkael,

    I am facing an issue with my search where my custom managed properties are not showing any result on custom Display Template associated with Custom Result type which is optimize for frequent use, synced, as well as using single template for all result type for my search web part.
    But don't why I am not able to retrieve any value for custom managed property.

    There is just one catch, The site for which I am searching the data, that site is still using old look and feel of SharePoint 2010. But my search center site is having SharePoint 2013 look and feel.

    Will it make a difference and can create issue with search and retrieval of custom managed property.

    Thanks much and let me know in case have any doubts.

    ReplyDelete
    Replies
    1. Doesn't matter of the site is in 2010 mode. You should check using the SharePoint 2013 query tool if you are getting values in the mp's. Also, on what level/site did you do the mapping from cp to mp?

      Delete
    2. Thanks Mikael,

      I have checked in query tool, I am not getting any value there either. Getting value for my custom LastName managed property, may be because I have mapped this LastName managed property with default and custom lastname crawled property.

      I have done this mapping from Central Administration "Search Schema".

      Delete
    3. If you're not getting data it seems you might have mapped wrong? What's the internal column name, and which cp did you map? And you have full crawled the 2010 content after the mapping?

      Delete
    4. Also Mikael,

      I have created a post on MS SharePoint 2013 Search forum. You can get further details from there as well.

      https://social.technet.microsoft.com/Forums/office/en-US/a751c991-9f47-4bd2-bc92-a61b8c5a996f/custom-managed-properties-showing-blanknull-value-in-itemdisplay-and-itemdisplayhoverpanel?forum=sharepointsearch#a8709876-d07d-48a8-ae90-1dc8edfac4f7

      Delete
    5. Yeah I have done full crawl several time, one full crawl is running now as well.

      I'll see internal name for columns and will validate whether my mapping is correct or not. I'll update you ASAP.


      Thanks very much for all your inputs

      Delete
    6. Also see http://techmikael.blogspot.no/2014/09/debug-crawled-properties-and-creating.html on how to check ULS on the content processing server(s) to see what cp data you are getting.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thanks Mikael,

    I think, I have figured out ..as you said above check internal name for columns, I have found my mapping was not correct I have mapped my managed properties by their corresponding display name crawled properties. Now I have added exact crawled proprieties based on their internal name.

    Waiting for my Full Crawl to complete.

    Just quick question Do I need to run full crawl again after this correct managed property mapping.

    Thanks much for all your help !!!!

    ReplyDelete
    Replies
    1. For any schema change you need to recrawl the items affected. Full crawl is easiest, but in 2013 via UI you can mark a site/list for recrawl. Also possible in 2010 with property bag mods...then an incremental will fix it. Or mark the items to be recrawled via the crawllog.

      Delete
    2. Thanks a ton Mikael, my issue has been resolved. Your comment to check internal name did the trick for me. I check in Search Query Tool and found my SharePoint 2013 list column have already defined managed properties which are populating the data correctly.

      I have updated my custom template with correct managed properties, synced the result type, Full Crawl....... Awsummmmmm getting result as expected...

      Thanks again for your prompt response.

      Delete