SOLVED

PnP Modern Search - Query Term - Search Hub and Associated Sites

Copper Contributor

Hi, I have created an Advanced Search page with PnP verticals that I would like to search individual hubs and their associated sites.    For example my verticals are as follows:

All Hubs, Knowledge Hub&Associated Sites, Communities Hub, Colleague Hub

 

The Knowledge Hub is the only one that has 30 plus associated sites and I would like to enter some query text in for the Knowledge Hub results to return results for that hub and all 30 sites.

 

Does anyone know what the query looks like for this?

 

I thought it was would be this: {searchTerms} RelatedHubSites:{Hub.Id}  but this only works on the hub where the search page has been developed, I am hoping there is away to look across another Hub in a separate site collection?

 

Thanks

5 Replies
best response confirmed by Team_Halls (Copper Contributor)
Solution

@Team_Halls You can specify any Hub Site's GUID, something like this:

`{searchTerms} RelatedHubSites:d63d74d9-dfb7-46ce-8f04-c1d6d674075c`

 

Thank you so much, after some googling I was able to find out how to get the Hub Site ID and add this to the query above and this is now working.
Thank you. Works for me as well.
To find your Hubid add: /_api/site?$select=IsHubSite,HubSiteId to site name
Do either of you know how to return exact keyword match when searching related hub sites? I saw an article about adding "" around "{searchTerms}" but that doesnt return anything at all!
Do either of you know how to return exact keyword match when searching related hub sites? I saw an article about adding "" around "{searchTerms}" but that doesnt return anything at all!
1 best response

Accepted Solutions
best response confirmed by Team_Halls (Copper Contributor)
Solution

@Team_Halls You can specify any Hub Site's GUID, something like this:

`{searchTerms} RelatedHubSites:d63d74d9-dfb7-46ce-8f04-c1d6d674075c`

 

View solution in original post