2

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

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 :

DepartmentId:"{24af7e54-d2f9-422d-a44e-6a6d40077d50}"

or (no more working)

DepartmentId:"{Site.ID}"

or (credits to @Alberto)

DepartmentId:{{PageContext.hubSiteId}}

if from a web-part.

7
  • 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. Jan 2 '20 at 16:02
  • 1
    You have double {{ and }} .... is it a typo ? – Steve B Jan 7 '20 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. Jan 7 '20 at 13:59
  • I use this syntax without issue. Can you describe what happens ? No result ? erro r? – Steve B Jan 7 '20 at 14:00
  • 1
    I confirm u that another workaround is to just use DepartmentId:{{PageContext.hubSiteId}}, it works as well :) – Alberto S. Jan 8 '20 at 10:23

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.