Forum Discussion
SharePoint Online - How can I add managed properties to search results?
- Jun 20, 2024
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 Property Crawled Property Description RefinableString01 ows__dlc_DocId Document ID RefinableString02 ows__dlc_DocIdUrl Document ID URL RefinableString03 ows_ProjectName SharePoint Library Choice Column "ProjectName" used in more Libraries. RefinableString04 ows__UIVersionString Library Element Version.
I have made these mappings in the PnP Search Results Webpart under Layout slots:Slot name Slot field Description DlcDocId RefinableString01 Document ID CustomDlcDocIdUrl RefinableString02 Document ID URL ProjectName RefinableString03 SharePoint Library Choice Column "ProjectName" used in more Libraries. CustomUIVersionString RefinableString04 Library 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>
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 Property | Crawled Property | Description |
| RefinableString01 | ows__dlc_DocId | Document ID |
| RefinableString02 | ows__dlc_DocIdUrl | Document ID URL |
| RefinableString03 | ows_ProjectName | SharePoint Library Choice Column "ProjectName" used in more Libraries. |
| RefinableString04 | ows__UIVersionString | Library Element Version. |
I have made these mappings in the PnP Search Results Webpart under Layout slots:
| Slot name | Slot field | Description |
| DlcDocId | RefinableString01 | Document ID |
| CustomDlcDocIdUrl | RefinableString02 | Document ID URL |
| ProjectName | RefinableString03 | SharePoint Library Choice Column "ProjectName" used in more Libraries. |
| CustomUIVersionString | RefinableString04 | Library 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>