Search using a SharePoint Hub Source

Reading Time: 3 minutes

I recently blogged about using SharePoint site scripts and a site design to build a standardized Project Site template. It provisioned the site with some standardized SharePoint Information Architecture (IA), updated the navigation and joined it to an existing Project SharePoint Hub site – the Project Hub. The design included these IA artifacts:

  • 2 Site columns: DocumentType (choice), ProjectName (single line of text)
  • Document content type: Project Document
  • Document library: Project Documents

Link to my previous post: Building a Modern Flat Project Hub using Site Designs

As a follow-up to that post, I’ll demonstrate how to leverage the above information architecture when summarizing content at the Hub level. For example, you might want to show all Project Charter documents for Project sites joined to the Hub. Let’s see how this is done…


How it’s Done

The choice site column, DocumentType, has been consistently applied to all Project sites by the createSiteColumnXml site action applied for the Project site design: (if you don’t see the expanded source, click the link to view the JSON code for the site column)

Because the site column name has been standardized across all Project sites, the same-named managed property has been generated in the search schema for each site and is available at the tenant level search schema as well; no additional mapping is required. Because of this, it is a scaleable solution. You can add additional project sites and the SharePoint indexer will automatically create the same-named managed property for each. At the Hub level, you can leverage the managed property exposed by all the joined Project sites.

NOTE: this may be dependent on the site column type. In this post, I used a choice column type. I will test out other column types and blog about that experience as well.


Seed some Content

For each of the Project sites, sample documents have been uploaded and tagged with metadata. I’ve ensured one of the documents in each site has been tagged with a document type of Project Charter to demonstrate how they’ll be surfaced on the Project Hub.

For the DocumentType site column on each Project site:

  • a crawled property , ows_q_CHCS_DocumentType, is automatically created
  • a managed property, DocumentTypeOWSCHCS,  is automatically created
  • they are automatically mapped to each other (image)
Crawled Property
Crawled property and managed property mapped for Site column DocumentType

I’ll use the DocumentTypeOWSCHCS managed property as a filter on the Hub to display all documents of a specific type, Project Charter in this example.


Build the Modern Page

To do this, create a new modern page and add a Highlighted Content web part to it. Since we want to automatically surface all Project Charters across any Project site joined to the Project Hub, we’ll use the source All sites in the hub and the DocumentTypeOWSCHCS managed property filter.

… and here is what the web part will return. In this example, I’ve created 3 Project sites using the Project Site design described in my previous post and I’ve uploaded numerous documents in each, 1 of which is a Project Charter. The Project Charters for all 3 sites are returned in the results indicated by the yellow star icon.

HCWP for Hub Scope

This is great news! Start to think of ways you can leverage the power of search across sites you’re joining to SharePoint hubs. Remember, you’ll need to ensure you have a consistent IA to work with (site columns and content types) before building any search solution. This is why planning for consistent site and information architecture is key!

Thanks for reading.

-JCK

One comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.