How can I search in document library from the root folder with fields that exist in the files to get the target files using pnp modern search

Amonsonra 1 Reputation point
2022-06-27T22:12:16.823+00:00

For example, if I am in the root folder in a document library and want to search for the files with fields that don't exist in the root folder,

is there a way to do that with PNP modern search?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,081 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,995 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,615 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,231 Reputation points
    2022-06-28T08:11:15.317+00:00

    Hi @Amonsonra ,

    According to my research and testing, you can use the following query in Query template to search from the root folder in document library, then you can use the fields to search for files.

    {searchTerms} path: https://xxxxx.sharepoint.com/sites/zellatest/LibraryName/FolderName  
    

    Please follow these steps:

    1. Choose PnP-Search Box and PnP-Search Results.
      215673-image.png
    2. Edit PnP-Search Results web part and input {searchTerms} path: https://xxxxx.sharepoint.com/sites/zellatest/test/folder to Query template. Then click Apply.
      215665-image.png
    3. Go to "Available connections" ->> Click Use input query test ->> Choose Dynamic value ->> Choose PnP -Search Box in Connect to source ->> Choose Search query in PnP -Search Box's properties.
      215636-image.png
    4. Save and you can use the fields to search files .
      215675-image.png

    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.


    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.