Forum Discussion

LadislavStupak's avatar
LadislavStupak
Brass Contributor
Jun 17, 2024
Solved

SharePoint Online - How can I add managed properties to search results?

Dear Ladies and Gentlemen,   How can I add managed properties to search results in SharePoint Online?   I have some crawled properties matched with manged properties and also with refinable prope...
  • LadislavStupak's avatar
    Jun 20, 2024

    LadislavStupak 

     

    This video from Dan from Academy 365 helped me a lot:

     

    SharePoint Tutorial - How to build a custom search page experience


    https://www.youtube.com/watch?v=H4HMOnnfx2w

     

    "PnP Modern Search v4" is used there and explained how it works. It is a very good solution.

     

    https://microsoft-search.github.io/pnp-modern-search/ 

     

    I have just made some changes, because I wanted to display more properties in the search results.

     

    I have made these mappings in the SharePoint central administration under Search:

     

    Managed PropertyCrawled PropertyDescription
    RefinableString01ows__dlc_DocIdDocument ID
    RefinableString02ows__dlc_DocIdUrlDocument ID URL
    RefinableString03ows_ProjectNameSharePoint Library Choice Column "ProjectName" used in more Libraries.
    RefinableString04ows__UIVersionStringLibrary Element Version.


    I have made these mappings in the PnP Search Results Webpart under Layout slots:

     

    Slot nameSlot fieldDescription
    DlcDocIdRefinableString01Document ID
    CustomDlcDocIdUrlRefinableString02Document ID URL
    ProjectNameRefinableString03SharePoint Library Choice Column "ProjectName" used in more Libraries.
    CustomUIVersionStringRefinableString04Library Element Version.

     

    And I have added this code in the Tag object:

     

    <div>
       {{#if (slot item @root.slots.CustomDlcDocIdUrl)}}
          <span></span><a href="{{RefinableString02}}">{{RefinableString01}}</a></span>
       {{/if}}
       {{#if (slot item @root.slots.CustomUIVersionString)}}
          <span>Version: {{RefinableString04}}</span>
       {{/if}}
       {{#if (slot item @root.slots.ProjectName)}}
          <span>{{RefinableString03}}</span>
       {{/if}}
    </div>