04-12-2019 11:32 AM - edited 04-08-2020 04:49 PM
04-12-2019 11:32 AM - edited 04-08-2020 04:49 PM
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.
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.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.
05-31-2019 03:08 PM
Hello Kerem. Two questions about this setting:
Thanks in advance!
06-02-2019 10:34 PM
Hi @tg_olympus, Yes, this will take effect for the new search box in the header as well.
This only applies to modern site search results. Lists and Libraries will continue to search in that particular list or library. If you click on the link at the bottom of lists and libraries to expand the search, you will be able to get to modern site search results, which will respect this setting.
06-03-2019 12:53 PM
Cool, we just tried it. It works to a point but it seems to be still showing local results in the search results drop down. Would that be fixed up in the future?
06-03-2019 11:12 PM
Thank you @tg_olympus! Yes, making the suggestions that appear under the search box to have the same scope is something the team is working on.
06-04-2019 06:10 PM
I have updated the search scope using powershell on comms/teams site but still the results are getting redirected to site level
Powershell Result after running the script on site : $web.SearchScope
Can you confirm if i am missing something
06-05-2019 05:32 AM - edited 06-05-2019 05:33 AM
Are the results that are not tenant wide in the searchbox or is it on the search results page after performing a search by hitting enter in the searchbox?
Also to verify that your site has been set to tenant you can try adding /_api/web to the end of the site url and searching in the text in the browser for searchscope and what value is set there.
06-05-2019 06:54 PM
Powershell result :
Search result in the site url after the change >> _layouts/15/search.aspx/siteall?q=keyword?
06-05-2019 09:39 PM
Setting looks correct, one thing we are working on is enabling hub sites for honoring the search scope. This is currently work in progress, so one source of this is if your communication site could be set up as hubsite?
Could you please verify that your site is not a hubsite?
06-05-2019 10:27 PM
No communication site is not a hub site, i also tested on Modern team site but it also did not work on that one also.
06-05-2019 10:33 PM
@Kanwar Jot Singh, sending you a private message where we can try to figure out your specifics.
06-14-2019 01:36 PM
06-20-2019 09:37 PM
07-03-2019 01:09 AM
07-23-2019 07:25 AM - edited 07-23-2019 07:27 AM
@Kerem Yuceturk Greetings - Are there plans or is there a way to control what is displayed in the result details? For example we have a description in the page details, but the results return the first few lines on the page. Same with libraries or lists. Return title or subject information?
07-24-2019 07:41 AM
@RickyB, we noticed the issue as well where some of our users were not seeing the result cards, and addressed it recently. All Targeted Release users and tenants should see the answer cards now while they are searching at the organization level. We hope that this will be available more broadly by September.
07-24-2019 07:49 AM
@Catherine Billick, we are working on a feature called modern display templates that will allow you to do this. My best estimate at the moment is that this will be available in the first half of 2020, we can provide a better estimate as we make more progress in our implementation.
07-24-2019 09:57 AM
@Kerem Yuceturk - Super! The feature will help the results be more user-friendly. Thanks for the quick reply.
07-26-2019 07:34 AM
@Kerem Yuceturk Here is an edit to update multiple sites.
08-01-2019 09:49 AM
I came here specifically looking for this feature, thank you for posting. Looking forward to updates to make it easier.