Using either Search Query tool or modern search WebParts (SPFx), is it possible to filter results from a specific hub site or site in a hub site ?

In the search query tool view all properties dialog, I don't see any managed property that suggest this is possible.

2 Answers 2


Ok, quite simply actually.

Thanks to this issue, I found that the DepartmentId corresponds to the hub site.

So, this KQL filters on the hub site :


or (no more working)


or (credits to @Alberto)


if from a web-part.

  • I am trying to use the current site ID in my search query, but it doesnt work... any idea/suggestion? DepartmentId:{{Site.ID}} {searchTerms}
    – Alberto S.
    Commented Jan 2, 2020 at 16:02
  • 1
    You have double {{ and }} .... is it a typo ?
    – Steve B
    Commented Jan 7, 2020 at 13:28
  • I tried with double {{ and single {, but never got it to work. Can you confirm that if I run such KQL sentence, it will perform the search filtering results by DepartmentId={current site ID} ( in order to perform searches from the central hubsite itself ). thanks
    – Alberto S.
    Commented Jan 7, 2020 at 13:59
  • I use this syntax without issue. Can you describe what happens ? No result ? erro r?
    – Steve B
    Commented Jan 7, 2020 at 14:00
  • 1
    I confirm u that another workaround is to just use DepartmentId:{{PageContext.hubSiteId}}, it works as well :)
    – Alberto S.
    Commented Jan 8, 2020 at 10:23

Tip. If you're using PnP Modern Search Solution V4, you need to escape the curly braces.

You can escape curly braces characters using '' to avoid: ex: DepartmentId:{edbfd618-ef1d-4cc5-a214-95bf44ddf4ee}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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