PnP – Office 365 Starter Intranet Solution (Part 6: The search implementation)

PnP – Office 365 Starter Intranet Solution (Part 6: The search implementation)

Content type Blog Post
Author Franck Cornu
Publication Date 28 Mar, 2017
Reading Time 7 minutes

In this part, I will talk about the search experience implemented in this sample. For now, to implement the search feature in a SharePoint intranet solution, you can typically use two main strategies:

  • Leverage the OOTB search features*
  • Implement your own solution

Because I’m a strong supporter of the OOTB approach, I opted for the first solution. SharePoint search features are very powerful and implement your own search experience can be very time consuming just to equal these capabilities so before choosing a custom approach, you have to evaluate the effective gain of doing this.

The main downside of using the OOTB search features is that they are isolated from the rest of the Office 365 environment. For example, if you want to benefit of the Graph API, you have no choice to implement you own components. In the very next future, the new SharePoint Framework may help to do build customized experience more easily ;).

* I don’t mention the search feature coming with the « SharePoint » tile because it is very limited.

The OOTB search features used in this sample are:

  • Search Web Parts with custom display templates (Search Results, Content Search and Refinement panel).
  • Results sources.
  • Custom search schema.
  • Query rules.

Archive and category pages management

An « archive » page is typically the page accessed by clicking on the « See all news » link at the bottom of a list or a carousel component. Instead of implementing a dedicated search page to display all the news, this feature is mutualized with the global search results page. At the end, it is only a refined query on the « Intranet » search category only for the « news » content type. This query is built dynamically like this:

Notice I use a refinement query (« r » parameter) instead of a direct query (the « k » parameter) because I don’t want to show it in the search box and the search results (which are automatically grab the entered keywords via the « k » query string parameter).

A category page is slightly different than an archive page. It represents a page for a specific navigation node. For example, the « News » node is a category page and if you click on it you might expect to see all the news of the portal. Because, like archive pages, we don’t necessary want to put the whole refinement query in the navigation link property manually (because it can be very long and complex), we can use search query rules to simplify instead:

 

Note: If you don’t want to manage category pages, you can just leave blank the navigation link for concerned taxonomy terms.

Notes

  • As a best practice, I don’t modify any of the default search managed properties. I always reuse one of the predefined ones.
  • I always use an alias name (instead of « RefinableStringXX« ) to easily reference properties in display template or search queries.
  • Search schema customizations are done within the site collection scope to not interfere with the global tenant search schema configuration. I simply export the whole search configuration (search schema, result sources, etc.) as XML using the export option in the site settings. The import is done via the PnP cmdlet  Set-SPOSearchConfiguration -Path $SearchConfigurationFilePath -Scope Site

Taxonomy refiners special case

For taxonomy refiners, I use the ows_taxid_xxx crawled properties instead of the « text » ones. Remember, in the previous article, I said refiners were not translated automatically by SharePoint so I want to get the term id and using code, get the right label according to the intranet current language.

It is done through a custom binding handler used in the display template:

About the Author

Franck Cornu
– LinkedIn: HTTPS://CA.LINKEDIN.COM/IN/FRANCKCORNU
– Twitter: @FRANCKCORNU
– Blog: HTTP://THECOLLABORATIONCORNER.COM/

Reference

Cornu, F. (2016). PnP – Office 365 Starter Intranet Solution (Part 6: The search implementation) [online] Available at: http://thecollaborationcorner.com/2016/09/08/part-6-the-search-implementation/ [Accessed 24 Mar. 2017].