Forum Discussion
paulpascha
Feb 07, 2017Bronze Contributor
Search Site Collections by URL
I am having troubles defining a Search Query in a Search Results WebPart.
In our tenant we have multiple site collections. We've chosen to use a naming convention in Site Collection URL's. Based on this naming convention I want to list all sites matching this convention.
The list below shows some sample URL's
https://tenantname.sharepoint.com/sites/demo1-departmentx https://tenantname.sharepoint.com/sites/demo1-departmentx-projectA https://tenantname.sharepoint.com/sites/demo1-departmentx-projectB https://tenantname.sharepoint.com/sites/demo1-departmentx-projectC
On the site demo1-departmentx I want to list all sites in my tenant that start with the same URL. First I configured my query using the Query Builder based on the "Path" managed property as follows:
contentclass:STS_Site Path={SiteCollection.URL}*
This only returns the demo1-departmentx site. I searched the internet and found some articles explaining this behavior. For example, this one:
https://blogs.technet.microsoft.com/peter_dempsey/2014/04/08/sharepoint-2013-searching-for-a-url
Following the suggestions in this article, I mapped the same crawled properties that are mapped to the Path Managed Property to RefinableString00 and changed my query to use RefinableString00. First it gave me no results at all. I had to change the operator from "=" to ":" to get the same result as before but still not what I want.
contentclass:STS_Site RefinableString00:{SiteCollection.URL}*
Any suggestions?
Actually when the query is like the below, the url is contains double-quote at the start and end.
contentclass:STS_Site Path:{SiteCollection.URL}*
Due to this the final path in the query looks like
Path:"https://tenantname.sharepoint.com/sites/testsite"*
But if you can hard-code the path, the search results are correct
contentclass:STS_Site Path:https://tenantname.sharepoint.com/sites/testsite*
This information may be useful for you to proceed further.