Jun 17 2024 10:14 AM
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 properties like RefinableString01.
I have also created custom search result page.
I have also updated the CustomString.js file like that:
But how ca I add these properties to the results of the search. So that these values will be displayed with the information about documents like title and URL address?
In the SharePoint Server it was possible to do.
Thank you
Ladislav Stupak
Jun 20 2024 07:18 AM
Solution
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>
Jun 20 2024 07:18 AM
Solution
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>