SOLVED

Configure modern search results to search all of your organization (rather than the current site)

Microsoft

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 organizationSearching 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.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.

77 Replies

@Kerem Yuceturk -  Suggestion you may already have on your list.

 

Search result returns the site title.  Problem is it also returns the web address name of the list and library instead of the title which would be more user-friendly.

 

Example:  Document resides in a library with the title of "Employee-New" .  Web address for the library is newterm.  

Search.JPG

 

Search2.JPG

I 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 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 

@chuckingerman, thank you for reporting this. We filed a bug on this and will address it as quickly as possible.

@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. 

Hi 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?
I 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
@Kerem Yuceturk Is there any update on being able to set the scope to be sites in the hub? I tried it recently and it doesn't seem to work yet. My understanding is you were working on this and eventually a value of 2 for DefaultScope would do this.

Thanks

@Kerem Yuceturk  : Thanks for post, it is really helpful. I have two questions

1) Can we configure Modern SharePoint site search with the enterprise search center site. i.e.add url of search results page in search settings of modern site? 

2) Can we add two result blocks in one Query rule, In my case I am adding one from SP onprem remote url and one from SP online. At a time only one result block display results in Modern site search.

 

Thanks,

Swapnil 

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

@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.

@Kerem YuceturkWhat about SharePoint Server 2019 On-Premise? Could you give us an appropriate solution?

@Kerem Yuceturk 

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 

@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?

@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-extendin... 

 

That being said, having more options to control search via PowerShell / UI is a must I think for Intranet deployment.

Thanks, 

-Max

@Kerem Yuceturk I'm curious on the status as well. This is something important to the success of our newly launched intranet. Being able to set a site to search across all sites in the hub will be a huge win.

Hi @Colleen Parker and everyone,

 

We are working on adding setting the search scope to hub capability now. Please stay tuned. My best estimate for availability would be around April.  

@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.

Hi @Vadimg, sorry, this capability is only on SharePoint Online at the moment.