BLOG
Cloud Solutions
November 25, 2024

From Chaos to Clarity: Mastering SharePoint Search with PnP Modern Search

Haseeb Minhas
5 min read

Alright, let’s get real for a second. SharePoint search—oh, what a journey it can be. You type in what you think is the right keyword, hit enter, and then… a treasure trove of almost-but-not-quite-right results. We’ve all been there. But here’s the thing: it doesn’t have to be that way. That’s where PnP Modern Search comes in. Think of it as your overachieving friend who not only shows up on time but also brings snacks and organizes the group project. It’s an open-source solution that adds features like faceted search, query suggestions, and refiners, making your search experience so efficient you’ll wonder why you put up with anything less. And no, we’re not telling Microsoft Search to step aside—we’re just giving it a boost. Together, they’re the dream team for tailored search applications that actually make sense. So, buckle up; we’re diving into how you can create custom search pages that make you, your team, and your SharePoint users happy.

Disclaimer: Before you dive headfirst into the wonderful world of PnP Modern Search, take a moment to evaluate your organization’s search needs. Because while it’s a fantastic tool, it won’t magically organize your chaotic file naming conventions or locate that one document named “Final_Final_UseThisOne_v3.5.docx.” Consider it an upgrade to your search game, not a time machine for your SharePoint sins.

Deploy PnP Modern Search Web Parts

Step 1: Downloading the PnP Modern Search Package

Alright, time to roll up your sleeves and get things started. The first step in this adventure is deploying the PnP package to your tenant. Sounds fancy, right? Don’t worry, it’s basically just downloading a file—but with a bit more purpose than your usual cat meme binge.

Head over to the PnP Modern Search releases page to grab the latest version. Now, here’s where things get interesting. You’ll notice there are two major versions available: v3 and v4. Let me break it down for you:

  • Version 4 is the shiny new sports car of PnP Modern Search, built on a brand-new code architecture and equipped with exclusive features like the Microsoft Graph Search API.
  • Version 3? It’s the reliable old sedan that’s still getting bug fixes and updates but isn’t taking any new passengers (read: no new features).

Here’s the catch: there’s no upgrade shortcut from v3 to v4. If you’re currently cruising on v3 and thinking of switching to v4, you’re going to have to park one and start fresh with the other. Oh, and if you’re new to this whole thing? Skip the nostalgia and go straight for v4—trust me on this.

When you’re ready, scroll down to the Assets section on the releases page, find the .sppkg file, and click. That’s it—you’ve officially taken your first step into the world of smarter, snazzier SharePoint search. 🎉

But don’t get too comfortable—we’ve got a bit more work to do!

searchexplained

Step 2: Deploying the PnP Modern Search Package to Your Tenant’s App Catalog


Now that you’ve downloaded the PnP Modern Search package (and are feeling like a SharePoint rockstar), it’s time to deploy it to your tenant’s App Catalog. Think of the App Catalog as SharePoint’s exclusive VIP lounge—a special site collection where all the cool apps hang out, ready to serve your organization.

If you already have an App Catalog, congratulations! You can jump straight to deploying the PnP Modern Search package there. Just a quick upload, and boom—your tenant is one step closer to search nirvana.

No App Catalog? No problem! You’ll need to create one. It’s not rocket science, but it’s an important prerequisite to get your search enhancements rolling. Think of it like setting up a proper home before inviting all your fancy apps to the party.

And hey, if this is sparking your curiosity about Microsoft Search, we’ve got you covered. Check out our Training Center for all the tips, tricks, and tidbits to become the office search guru.

Once the package is in the App Catalog, you’re officially locked and loaded. Now let’s keep this momentum going!

Step 3: Creating a New SharePoint App Catalog

If your organization doesn’t already have an App Catalog, don’t worry—you’re about to earn your “SharePoint Builder” badge. Creating one is pretty straightforward, but here’s the catch: you’ll need to be a tenant administrator to make it happen. So, if you’re not the admin, now’s the time to butter them up with coffee or compliments.

Once you’re ready, follow these steps:

1. Head over to the Microsoft 365 Admin Center or the SharePoint Admin Center—whichever feels like home.

2. In the left-hand menu, click on “More features” (because apparently, App Catalog creation isn’t a “regular feature”.

searchexplained

2. Select “Apps” from the list, and you’ll land in the magical realm of App Catalog management.

3. Click on “New App Catalog”—and here’s where the real fun begins. Fill out the form to create a shiny, new site collection dedicated to your organization’s apps.

searchexplained

Once the form is submitted, SharePoint works its magic, and voilà! You’ve got yourself an App Catalog. Think of it as the foundation for all your app-deployment dreams.

With the App Catalog in place, you’re now fully equipped to move forward and deploy your PnP Modern Search package. Things are starting to get real!

Step 4: Deploying the PnP Modern Search Package

Now that your App Catalog is ready (or maybe you’ve been ahead of the game and had one all along), it’s time to roll out the PnP Modern Search package and make SharePoint search dreams come true. Here’s how to get it done:

1. Open the App Catalog: Navigate to your App Catalog URL, and click on “Apps for SharePoint”. This is the hub where all your apps live.

searchexplained

2. Upload the Package: Click the Upload button, then select the PnP Modern Search package file you downloaded earlier. It’s like adding a new member to the SharePoint family.

searchexplained

3. Deploy and Trust: When prompted to trust the PnP Modern Search Web Parts package, you have two choices:

  1. Deploy everywhere: Tick the checkbox to make the package available across all site collections.
  2. Selective deployment: Leave the box unchecked if you only need the package on a few specific sites.
    Once you’ve made your choice, click Deploy, and let SharePoint do its thing.
searchexplained

After deployment, you’ll see the PnP Modern Search Web Parts proudly sitting in your App Catalog, ready to serve your users.

A Quick Note About Version History

For those of you keeping track, the process for deploying version 4 of PnP Modern Search got a much-needed glow-up in March 2021. Gone are the days of juggling two separate packages—everything is now bundled into a single npm package for simpler deployment.

With the deployment complete, your PnP Modern Search setup is well on its way. Next up: putting those web parts to good use!

Step 5: Adding the PnP Modern Search Web Parts to Your Page

With the package deployed, it’s time to bring your PnP Modern Search Web Parts to life by adding them to your SharePoint page. This is where the magic happens—turning a regular page into a custom search powerhouse.

Start with the Basics

  1. Open the page you want to edit.
  2. In the web parts list, search for “PnP” to find the PnP Modern Search Web Parts.
  3. You’ll see a list of options, including:
    • PnP Search Box
    • PnP Search Filters
    • PnP Search Results
    • PnP Search Verticals

To get started, you’ll need at least two web parts: the PnP Search Box and the PnP Search Results.

Adding the Search Box Web Part

  1. Edit your page and add a new web part.
  2. Search for PnP Search Box and add it to your page.

No further configuration is required at this stage—simple, right? This web part will act as the starting point for your search functionality.

Adding and Configuring the Search Results Web Part

Next, you’ll add the PnP Search Results web part and connect it to the Search Box:

  1. Add the PnP Search Results web part to your page.
  2. Open the properties for the Search Results web part.
  3. Navigate to Page 3 of 4 in the web part’s settings.
  4. Turn on “Use input query text”.
  5. Select “Dynamic value” under the connection settings.
  6. In the Connect to source dropdown, choose “PnP – Search Box”.
  7. In the PnP – Search Box’s properties dropdown, select “Search query”.

Save the page, and just like that, you’ve created your first custom PnP search page! 🎉

Adding Additional Query Conditions

Need to get fancy with your search? You can limit the scope or apply filters using KQL (Keyword Query Language) in the Search Box settings.

For example, to display only documents and exclude pages from a specific site, use the following query:

{searchTerms} IsDocument:1 -fileextension:aspx -Path:"https://yourtenant.sharepoint.com/sites/yoursite*"

Here, {searchTerms} refers to the input query text sent from the Search Box to the Search Results web part.

Adding Search Filters for a Refined Experience

Once your page is equipped with a Search Box and Search Results web part, the next step is to add the PnP Search Filters web part to fine-tune your results:

  1. Edit the page and add a new web part.
  2. Search for PnP Search Filters and add it to your page.

To make the Filters web part work, you’ll need to define connections:

  1. Receive results from the Search Results web part:
    • Open the Filters web part settings.
    • In the Use data from these web parts dropdown, select the Search Results web part.
  2. Send filters to the Search Results web part:
    • Configure the Filters web part to send the filtering criteria to the Search Results web part.

Once connected, the Filters web part will dynamically display relevant filters based on the results from the Search Results web part, including item counts for each filter.

Step 6: Connecting and Customizing the Filters and Search Results Web Parts

With the PnP Search Box, Search Results, and Filters web parts on your page, it’s time to make sure everything is playing nicely together. This step connects the dots, ensuring selected filter values update the search results dynamically.

Connecting the Search Results Web Part to the Filters Web Part

  1. Edit the Search Results Web Part:
    • Open your page for editing, select the Search Results web part, and click on Edit.
  2. Navigate to the Filters Settings:
    • Scroll to Page 3 of the web part properties.
    • Look for the radio button labeled “Connect to a Filters web part” and select it.

This connection allows the Search Results web part to receive and apply the filtering criteria set by the Filters web part.

Customizing the Filters Web Part

The Filters web part is highly customizable, giving you control over the look and functionality of the filters displayed to users. To tailor the experience:

  1. Edit the Filters Web Part:
    • Open your page for editing, select the Filters web part, and click Customize Filters.
  2. Add, Remove, or Edit Filters:
    • On the customization page, you’ll be able to manage your filter settings to suit your organization’s needs.

Here’s what you can tweak for each filter (refiner):

  • Display Name: The label users will see on the page.
  • Filter Field: The name of the refinable managed property to be used as the filter criteria.
  • # of Values: The number of filter values to display.
  • Template: Choose how the filter will appear—checkbox, date range, combo box, etc.
  • Expand by Default: Decide if the filter should appear expanded or collapsed initially.
  • Show Count: Display the item count next to each filter value.
  • Multi Values: Enable users to select multiple values within the same filter.
  • Operator Between Values: Set the logic (AND/OR) for multi-value filters.
  • Sort Values By: Choose to sort filter values by name or count.
  • Sort Direction: Define whether sorting should be ascending or descending.

Pro Tip: Refinable Managed Properties

When configuring your filters, consider using Refinable Managed Properties to tailor the search results further. These properties give you precise control over what’s being filtered and displayed, enhancing the user’s ability to zero in on the information they need.

With these configurations in place, your Filters and Search Results web parts will work seamlessly, giving users a dynamic and responsive search experience. Next step: sit back and marvel at your SharePoint search masterpiece—or tweak it endlessly because perfection is a journey!

SCHEDULE A CALL

Real-time Support

One of our team members will get back to you within the next business day.

24/7 support

+1 833 489 2262

Real-time support

intake@bitsummit.ca

*For a quicker response, you can call or email us.

Your name *
Email address *
Email address *
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.