0

We have about 20 departments with about 100 sites (average) connected to each department. So, that is a total of some 2.000 sites. Per department I have a hub site and like to use PnP Modern Search to list my sites connected to the hub. I use three web parts: a search result web part, a search box to search (optional) for site title, and a filter web part to filter the sites from the result set. The filter uses several properties from the site property bag. The hub represents all sites of some department. At this moment I use this in the Query Template

SiteTitle:{searchTerms} AND contentclass:STS_site

Now I get all sites. Of course, trimmed-search makes sure I see only the sites I can access, so I do not see all 2.000 sites. But I want to see only my sites of my department.

What do I need to add to the query to be able to filter for sites connected to this hub?

The alternative is to add a site property to group the sites that belong to a department, but that is a lot of maintenance effort when a department changes the name or when any other organisation change takes place. Just working with the hub-structure seems the best way.

0

If you haven't found a solution yet: Try to get the hub ID (DepartmentId) using the search query tool and then add it to your search query. Something like:

DepartmentId:{eecd8f40-298b-424a-8266-91d1ce8509c3}
1
  • Yes, the solution using DepartmentId works: SiteTitle:{searchTerms} AND contentclass:STS_site AND DepartmentID:{{PageContext.hubSiteId}} Thanks for the tip! – Peter van Rossum Mar 2 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.