SharePoint PNP Search Function

Olivia 0 Reputation points

I need to set up a PNP search function to only search a specific site, only shows documents, and doesn't show any results when no criteria is entered. 

The below query works how I want it to search, however it shows results when I haven't entered in any criteria.

{searchTerms} IsDocument:1 -fileextension:aspx Path:"*"

By just entering in:


it only shows results when I have entered in a search criterion, however it doesn't allow me to restrict my results to 1 site and document type. 

Any help would be appreciated. Thanks 

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,011 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 43,176 Reputation points Microsoft Vendor

    Try to use following search query.

    {?{searchTerms} IsDocument:1 -fileextension:aspx Path:"*"}

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.