Forum Discussion

Team_Halls's avatar
Team_Halls
Copper Contributor
Jan 12, 2023
Solved

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_Halls's avatar
      Team_Halls
      Copper Contributor
      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!
    • AlbertSP's avatar
      AlbertSP
      Copper Contributor
      Thank you. Works for me as well.
      To find your Hubid add: /_api/site?$select=IsHubSite,HubSiteId to site name
      • Team_Halls's avatar
        Team_Halls
        Copper Contributor
        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!
    • Team_Halls's avatar
      Team_Halls
      Copper Contributor
      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.

Resources