logo
search
SharePoint Document Issues

How to Configure PnP Search for a Single SharePoint Site

Elise WilliamsElise Williams Sep 30, 2026 869 views

Question details

The user needs to configure PnP Modern Search to return results exclusively from one specific SharePoint site, restrict the results to document files only, and display no results when the search box is left empty.

Product
SharePoint Online
Device & OS
not provided
Scenario
Customizing a modern SharePoint portal page to improve targeted document discovery using the PnP Modern Search web parts.
Observed behavior
Looking for the correct query template syntax and web part configurations to restrict the search scope and handle empty query states properly.
Before you start

Ensure you have Site Owner or Site Collection Administrator permissions and that the PnP Modern Search web parts are already deployed and added to your modern SharePoint page.

Solution 1Recommended

Modify the Search Query Template

Apply a specific search query template within the web part properties to restrict results to your target site and document types.

By combining the search term variable with KQL (Keyword Query Language) property restrictions, you can force the web part to strictly return documents from a designated path.

1
Edit the SharePoint page

Navigate to your SharePoint site, click on 'Edit' in the top right corner, and select the PnP Search Results Web Part to open its property pane.

2
Locate the Query Template

Go to the first page of the web part configuration settings and locate the 'Query template' text field.

3
Enter the restriction syntax

Input the following query string: {searchTerms} IsDocument:1 Path:"https://yourtenant.sharepoint.com/sites/yoursite*" (replace the URL with your actual tenant and site path).

4
Configure empty query behavior

Scroll through the settings pane to locate the toggle option that controls empty search behavior, and set it to not execute the query or hide results when the search input is empty.

5
Save and republish

Close the property pane and click 'Republish' to save your new search configuration.

Modify the Search Query Template
Check Syntax Details: Ensure you include the asterisk (*) at the end of your site path so the query includes all folders and sub-directories within that specific SharePoint site.
Free Microsoft Office alternative

Edit Your SharePoint Documents Seamlessly with WPS Office

While SharePoint helps you organize and find files online, you need a robust editor for your local workflow. WPS Office is a free, lightweight suite that seamlessly handles Microsoft Office formats, allowing you to open, edit, and save your downloaded SharePoint documents with zero hassle.

  1. 1. Download the software: Visit the official WPS Office website to download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the downloaded installer and follow the on-screen prompts to easily install the suite.
  3. 3. Open and edit files: Double-click any downloaded SharePoint document to open and seamlessly edit it within WPS Office.
Fully compatible with Microsoft Word, Excel, and PowerPoint (.docx, .xlsx, .pptx) formats used in SharePoint.Extremely lightweight and fast, launching in seconds for quick edits of your downloaded documents.Familiar ribbon interface ensures a smooth transition with zero learning curve for traditional Office users.Includes an advanced built-in PDF editor for comprehensive local document handling.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PnP search box return all results when empty?

By default, search components may execute a wildcard query when no text is entered. You must explicitly toggle the setting within the PnP Search Results web part configuration to 'Hide results when query is empty' or prevent the search from executing.

How do I ensure only PDF or Word files appear in my SharePoint search?

You can modify your search query template by adding file type restrictions. Combine your query with commands like FileType:pdf OR FileType:docx alongside IsDocument:1 to limit the output to those specific formats.

Can I configure PnP Search to look across multiple specific SharePoint sites?

Yes. You can expand the query path restriction to include multiple distinct sites by using the OR operator in your KQL statement, such as: {searchTerms} IsDocument:1 (Path:"https://tenant.sharepoint.com/sites/site1*" OR Path:"https://tenant.sharepoint.com/sites/site2*").