Some tips and tricks on filtering by site Url (path) in query field in Microsoft 365 Search verticals
Path filter with trailing slash (“/”)
In November 2022 Microsoft rolled out an update for multiple search features, including checks on the path managed property for a trailing slash. Previously path filters were valid with and without trailing slashes.
Consider the following scenario.
Given the path filter with the contain operator (“:”)
These path could be matched with:
Path:https://contoso.sharepoint.com/sites/MySite Path:https://contoso.sharepoint.com/sites/MySite/subsite Path:https://contoso.sharepoint.com/sites/MySite2 Path:https://contoso.sharepoint.com/sites/MySite2/subsite Path:https://contoso.sharepoint.com/sites/MySite3
Obviously, the match intent is unclear. Adding a trailing slash clarifies that only MySite (and below) matches. So intended matches would be only:
Using SPSiteUrl property
The other option – use the SPSiteUrl property with the full path:
SPSiteUrl and Path properties use different matching strategies. When using contains operator (colon sign “:”) – SPSiteUrl will match the full value, while Path will do a “starts with” match.
DepartmentId is a search managed property used under Hub sites and propagated through all associated sites content.
That means if we want to scope down search to hub site with it’s content – we can use DepartmentId property, e.g.
instead of iteration through all hub sites and using path: property.
Pingback: DepartmentId for Enterprise Intranet Portal – Home Site and Search Scope and Relevance ⋆ m365 SharePoint Engineer