Forum Discussion
Configure modern search results to search all of your organization (rather than the current site)
Hey everyone,
We heard from many of you the need to be able to change the scope of your modern search results pages. When you create a new communication site or team site in SharePoint Online today, and type into the search box, you are taken to the modern search results page. This page shows results from your current site by default, and allows you to expand the scope of your search to the hub that the current site is associated with (if there is one), or to the whole organization.
But there is a desire for being able to change the behavior to always search over the whole organization, or across the hub a site is associated with, without needing an additional click, especially if the site in question will be used as a modern landing page for your organization.
Searching in a site will show results from that site (Strategy and Planning), with a control to expand the search scope to the hub (Sales) or the whole organization
I'm happy to say that with the latest version of the SharePoint PnP PowerShell extensions, it is possible to run a simple command as the site owner, and make your site use the organization, or the hub scope by default.
To change this setting:
1. Start PowerShell in administrator mode as you will be installing the PnP extensions.
2. Run the following commands to in this order:
PS C:\WINDOWS\system32> Install-Module SharePointPnPPowerShellOnline
# If you previously had installed this module, you may need to use the "-Force" parameter to install the newer version.
PS C:\WINDOWS\system32> Connect-PnPOnline -Url https://contosodemosg.sharepoint.com/sites/Strategy -UseWebLogin
# this will prompt you to sign into your site. Use the site owner credentials to sign in
PS C:\WINDOWS\system32> $web = Get-PnPWeb PS C:\WINDOWS\system32> $web.SearchScope = 1
# 1 for Tenant, 2 for Hub, 3 for Site, 0 for default behavior
PS C:\WINDOWS\system32> $web.Update() PS C:\WINDOWS\system32> Invoke-PnPQuery
After running these commands, the site will start to show results from the whole organization.After the change, results from the whole organization are displayed.To go back to the default setting, run the commands again with the value provided to "SearchScope" parameter to 0.
To search across the Hub, use 2 as the SearchScope value.
We will be providing a way to set this setting using the UI in a future release as well.
Updated in April 2020 to reflect the ability to search across Hubs.
Hi Rick DeFoe, we are actually working on making that happen. We hope that will be coming in the next couple of months.
77 Replies
- Jaymin PatelBrass Contributor
Kerem Yuceturk - We have unique situation. Our intranet site site just have landing page and links to all hubs (Company, My HR, Reference Library) in top navigation. The reason we have this set up as we can't have more than one level of hub (nested hub). How can we update search behavior so it will search only on root site for our intranet and multiple sites\hubs (Company, My HR, Reference library in our case)?
In our old intranet site (based on publishing portal), we had created custom search scope to restrict search into specific sites. How can we achieve similar behavior in modern communication sites?
- jaubrainCopper Contributor
Kerem Yuceturk I am new to Powershell. I have manage to login on SPO. But I am getting an error using the first commando ($web = Get-PnPWeb) see beneath. Can you guys and girls help me?
Get-PnPWeb : The term 'Get-PnPWeb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:8
+ $web = Get-PnPWeb
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-PnPWeb:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
- Joe VolkBrass Contributor
Kerem Yuceturk Has there been any update to this? We are deploying our intranet and we have the scope set to just what it is out of the box which gives us results from the sites connected to our intranet hub. The problem is that it doesn't give us the people search capability. When I set the scope to include all of SharePoint, I feel like our results are cluttered up with a lot of information and even OneDrive. Will we be able to add in the people Search without all of SharePoint?
- Kerem Yuceturk
Microsoft
Joe Volk , Max Goss , as you pointed out promoted results/answers as well as people are only available at the organization level, and not at site and hub levels. This is due to the challenge of not being able to easily scope these entities to the sites and hubs we are dealing with. While we don't have any plans on this at the moment, I am sending your feedback to some of my colleagues to consider. We will enable some capabilities to customize the verticals in the second half of the year as well.
At the moment, building a custom results page could be one solution for meeting this scenario.
- Max GossBrass Contributor
Joe Volk we are in the same situation for our Intranet deployment, We've gone down the route of tweaking the search so that it does include all of SharePoint, primarily so that people and promoted results are returned. What we really need is the ability to scope SharePoint search to a hub / collection of Hubs but have the ability to showcase People and / or promoted results.
In the latest version of SPFX I have seen a preview feature on search customisation which might help: https://developer.microsoft.com/en-us/sharepoint/blogs/announcing-sharepoint-framework-1-10-extending-sharepoint-framework-across-microsoft-365/
That being said, having more options to control search via PowerShell / UI is a must I think for Intranet deployment.
Thanks,
-Max
- Ezekiel_OpeCopper Contributor
Hello ,
I am trying to search for a document by the tenant search (contos.sharepoint.com/search ) and using the search query tool but I don't get any result. The column contains separator dot (e.g PCE 234.56) no result is returned nut when i search with the title of the document , results are returned for the same document.
I have created a managed property (searchable,query-able, Language, matchable, langauge, tokenization ) mapped to the crawled property.
Please any idea
- VadimgCopper Contributor
Kerem YuceturkWhat about SharePoint Server 2019 On-Premise? Could you give us an appropriate solution?
- Kerem Yuceturk
Microsoft
Hi Vadimg, sorry, this capability is only on SharePoint Online at the moment.
- Richard_ArriagaCopper ContributorThank you so much! It worked like a charm!
- Martin MeranerBrass Contributor
Hi,
I run into a similar issue, maybe someone has a good idea. I actually like the search scope to be at site level (like the default is), but have additionally the people search working for all our employees (AAD O365 accounts). Any trick to do that without coding stuff myself?
Best
Martin
- Shamilton950Brass Contributor
Hi Martin - I also would love the same structure of searching just the site content but allow for searching people. Did you ever find a way? ty
- Max GossBrass ContributorHi Kerem, this is a really useful feature, and will enable search on intranet sites to behave much more consistently. Thanks for enabling this!
Are there any plans to be able to modify the search settings to search the hub by default? For example if we have several Intranet sites connected to a hub it would be great if we could have an option to have all connected sites search all content in the hub by default. Ideally this would still bring back Promoted results which currently I know only feature if a global search is performed. Are there any plans for this?- Rick DeFoeIron ContributorI am hoping for this as well. We have just launched a new SPO intranet using modern SPO and hub sites and users are confused when searching from the hub vs searching on a child site.
I have been lead to believe they are working in this, and was told the following parameters values will eventually work for the various search scopes. I would love to get an update to know if it is still planned
DefaultScope = 0,
Tenant = 1,
Hub = 2,
Site = 3
- chuckingermanCopper Contributor
Kerem Yuceturk Thanks for the tip. Worked as you described. The only think I noticed is on the modern site I changed when you do the initial refresh of the page the search object says "Search in Sharepoint" when I return to the original page it says "Search in your organization"
It still searches across our tenant so the search is working just the description doesn't seem right
Thanks again for the tip and the powershell code
- Kerem Yuceturk
Microsoft
chuckingerman, thank you for reporting this. We filed a bug on this and will address it as quickly as possible.
- RahulBrillCopper ContributorI am using the Site administrator ID to make the changes but getting below error.
Invoke-PnPQuery : Access denied. You do not have permission to perform this action or access this resource.
At line:1 char:1
+ Invoke-PnPQuery
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-PnPQuery], ServerUnauthorizedAccessException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerUnauthorizedAccessException,SharePointPnP.PowerShell.Commands.Base.InvokeQuery- Kerem Yuceturk
Microsoft
RahulBrill, looks like a permission issue. Sorry it is hard to provide more guidance than that remotely. I'd look into all the security groups involved to make sure you have access, or try another admin user.
- RahulBrillCopper Contributor
Kerem Yuceturk I did found a way to execute the command.
it needs a tenant access right to execute the statement otherwise you end up in error.