Forum Discussion
Team_Halls
Jan 12, 2023Copper Contributor
PnP Modern Search - Query Term - Search Hub and Associated Sites
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
Team_Halls You can specify any Hub Site's GUID, something like this:
`{searchTerms} RelatedHubSites:d63d74d9-dfb7-46ce-8f04-c1d6d674075c`
Team_Halls You can specify any Hub Site's GUID, something like this:
`{searchTerms} RelatedHubSites:d63d74d9-dfb7-46ce-8f04-c1d6d674075c`
- Team_HallsCopper ContributorDo 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!
- AlbertSPCopper ContributorThank you. Works for me as well.
To find your Hubid add: /_api/site?$select=IsHubSite,HubSiteId to site name- Team_HallsCopper ContributorDo 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!
- Team_HallsCopper ContributorThank 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.