Using the Modern PnP Search Web Part 

For those familiar with the benefits of Modern PnP search web parts but intimidated by the setup, I have documented a minimal path to awesome for you. This guide does assume you have initial install complete. For more guidance on install, please see the Modern PnP search site.

These instructions go through adding a search box, filter, and results web part to a page. Please note, you can use a search results web part without a search box or filter. You may consider using only a search results web part when you want to display content on a page to put the documents in context and your search scope reduces it far enough that you do not need filters. 

Creating Managed Properties 

For any site column that you would like to use as a search filter, you will need to create a managed property. 

  1. Select the app launcher in the top left of the navigation bar 
  1. Select “Admin” 
  1. Select “Show all” then “SharePoint” 
  1. Select “More features” 
  1. Under “Search” select “Open” 
  1. Select “Manage Search Schema” 
  1. In the textbox to the right of “Managed property” type “refinable string” then select the green arrow 
  1. Select a refinable string by clicking on the title. Ensure the “MAPPED CRAWLED PROPERTIES” column is blank. 
  1. Scroll to the bottom of the page, under “Mappings to crawled properties” select “Add a mapping” 
  1. Search for the name of your column 
  1. Select the column (“ows” usually appears before it. For example, a column called “Year” will appear as “ows_year”) 
  1. Select “OK” 
  1. Select “OK” 

Building a Search Page 

Adding web parts to the page 

  1. Select “Edit” on the page where you want to add the web parts 
  1. Select “+” to open the modal box for web parts and search for “PnP.” 
  1. Add “PnP- Search Box,” “PnP- Search Filters,” and “PnP- Search Results” to the page 

If you have multiple versions of this web part, ONLY select the search web parts with “PnP” as a prefix. This is the most up to date version of the Modern PnP search web part. 

Setting up the search box 

  1. Select the edit icon (pencil) for the PnP- Search Box web part 
  1. Navigate to the third page using the next button.  
  1. Toggle “Use dynamic data source as default input” to On 
  1. Under “Connect to source,” select “PnP- Search Results” (there will be a web part GUID as well) from the dropdown menu 
  1. Under “PnP – Search Results’s properties” select “Search Results” again. There will be a unique code as part of the name. 

Setting up the search results 

  1. Select the edit icon (pencil) for the PnP- Search Results web part 

On the first page 

  1. Under “Available data sources” as “SharePoint Search” 
  1. Under “Layout slots,” select “Customize” 
  1. Under “Tags,” edit the slot field to prefix “Auto” to the existing text. The final text should read “Autoowstaxidmetadataalltagsinfo.” 
  1. Under “Selected Properties,” select every Site Column you need for your search query and search filters. 
  1. Toggle “Enable localization” to On 

On the third page 

  1. Toggle “Use input query text” to On 
  1. Select “Dynamic Value” 
  1. Under “Connect to source,” select “PnP- Search Box” from the dropdown 
  1. Under “PnP – Search Box’s properties,” select “Search query” from the dropdown 
  1. Toggle “Connect to a filters Web Part” to On 
  1. Under “Use filters from this component,” select “Filters” (there will be a web part GUID as well) from the dropdown 

Setting up the search filters 

  1. Select the edit icon (pencil) for the PnP- Search Filters web part 
  1. Under “Use data from these Web Parts,” select “Search Results” (there will be a web part GUID as well) from the dropdown 
  1. Under “Customize filters,” select Edit 
  1. Under “Display name” enter the text you want to appear on the page 
  1. Under “Filter field,” select the site column 
    IMPORTANT: Remember that you must select all site columns under “Selected Properties” in Step 13 
  1. Under “Template,” select the appropriate option which is usually Check box 
  1. Select “Expand by default” 
  1. Select “+” to add more filters, as needed 
  1. Select “Save” 

Common issues 

-The content types and site columns will not appear as available filters if content has not been tagged to them already 
-Site pages must be published after the content type or site column is edited

What’s next?

Let’s put this into context with some business use cases! In this blog series, we will discuss using Modern PnP search to support surfacing Human Resources benefits and company policies.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s