How to Restrict SharePoint Search Results for Lists and Libraries
Question details
The user wants to prevent SharePoint users from finding items outside a specifically filtered list or library view and needs to hide the 'Expand search to all items in this site' option.

- Product
- Microsoft SharePoint
- Device & OS
- not provided
- Scenario
- Managing search permissions and visibility limits within specific SharePoint lists or document libraries.
- Observed behavior
- SharePoint displays an 'Expand search to all items in this site' prompt by default, allowing users to search beyond the current filtered view without a native option to disable it.
Ensure you have Site Owner or Administrator permissions in your SharePoint environment to modify search configurations, adjust list settings, or deploy custom web parts.
Implement PnP Modern Search Web Parts
Deploy the open-source PnP Modern Search solution to gain granular control over search experiences and prevent site-wide expansion.
Since SharePoint does not natively support hiding the site-wide search prompt for individual lists, PnP Modern Search is the community-standard workaround. It replaces the default search box with customizable web parts.
Visit the official Microsoft Search GitHub repository and download the latest PnP Modern Search package.
Upload the downloaded package to your SharePoint Tenant App Catalog to make the web parts available across your sites.
Create a new Modern Page, then add the 'PnP Search Box' and 'PnP Search Results' web parts to the page.
Edit the PnP Search Results web part properties to restrict the query strictly to your targeted list or document library ID, effectively preventing outside searches.

Display the List on a Modern Page via Web Part
Embed the specific list or library onto a dedicated SharePoint page to control user interaction without exposing the main list search interface.
Manage Your Documents Seamlessly with WPS Office
While SharePoint search restrictions require advanced configuration, everyday document management shouldn't be complicated. WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office, offering an intuitive interface for editing, organizing, and securing your files.
- 1. Download the installer: Visit the official WPS website to download the free installation package for your operating system.
- 2. Install WPS Office: Run the downloaded installer and follow the on-screen instructions to complete the setup.
- 3. Open your files: Launch WPS Office and seamlessly open your existing Microsoft Office documents to start working immediately.

Frequently Asked Questions
Does SharePoint have a native setting to disable 'Expand search to all items'?
No, SharePoint does not currently offer a built-in toggle or out-of-the-box setting to hide this specific search expansion prompt for individual lists or libraries.
Can I use folder-level permissions to restrict search results?
Yes, search results in SharePoint are security-trimmed. If you remove a user's read permissions from specific folders or items, those items will automatically disappear from their search results regardless of how they search.
How can I exclude an entire list from SharePoint search completely?
Go to List Settings, click on 'Advanced settings', scroll down to the 'Search' section, and select 'No' under 'Allow items from this document library to appear in search results?'.
Is PnP Modern Search free to use?
Yes, PnP Modern Search is a free, open-source solution provided by the Microsoft 365 community, though deploying it requires SharePoint tenant administrator privileges.




