Custom Search in SPO using Out-of-the-Box features and Open Source Webparts!

As we all know, Search is extremely important in SharePoint. We have a lot of features out-of-the-box ready to help us configure a great Search, but we also have a great community out there working/contributing to open source Search webparts!

In this post, we’ll configure a custom Search. We’re going to scope it to a few Site Collections, and add the PnP Modern Search Webparts which are open sourced on Github.

Are you ready? Let’s go! 🙂


Create a Site Collection for the Search

In this scenario, we’re going to create a (blank) Communication Site. I find the design much better than a team site for a separate Search.

Communication Site creation


Custom Search



Deploy the PnP Modern Search webparts

If you navigate to the Github repository for the PnP Modern Search, go to releases, and download the latest package (pnp-modern-search-parts.sppkg) under “Assets”.

At the time of writing this post, we’re on version 3.8.0 from December 2019.

Modern Search release 3.8.0 – Dec 2019


Navigate to the App Catalog (hopefully already created in your tenant), and upload the .sppkg package

Upload .sppkg file


Then click on “Deploy” when prompted

The package has now been deployed 😊



Add the webparts to the Search site

Now’s the time to add those webparts to our custom Search!
Navigate to the Custom Search site >> click on the “gear icon” >> Add an app

And there it is!


Click on it, and wait for a few minutes for the app to be added to the site and be available amongst the webparts (until it’s not greyed out anymore)

Once they are available, you can add them to the site by editing the page.



Choose a layout for the Search site

I usually go for a 1-third right layout (2 columns), so I can have:

  • Verticals
  • Search Box
  • Search Results
  • Refiners (on the right)
  • Search pagination

But this entirely up to you how to organise according to your preferences 😉


Each webpart has a configuration panel that you can use to your liking. Just click on Edit and a blade will open on the right.


🎥 There is a fantastic 1hr video from the SharePoint PnP Developer Community that goes into detail on how to configure each of those webparts. Watch it!!



Scope the Search Results with Result Sources

Now we can scope the results so users only see content from specific Site Collections.

On the Custom Search site, navigate to the gear icon >> Site information >> View all Site Settings.
Under Search, click on Result Sources.

We are going to create a new result source and add 2x specific site collections.
In the Query Transform section, click on Launch Query Builder.

The below query will only target the 2x URLs mentioned, and remove any “views” from the results (-contentclass:STS_List_*.)


By clicking on Test Query, you can have a preview of what the results would look like 🙂
Then click OK and Save.

⚠️ Our new result source has been created, but one more thing: grab the ID of that result source for our Search Results webpart configuration.
Click on the result source >> look at the URL >> the end is the ID number (ex: sourceid=ab12345-cd678-……..)


Configure the Search Results with the Result Source ID

After configuring the other webparts (Verticals, Refiners…) to connect to the search results, let’s configure the Search Results with the Result Source Identifier.
Edit the page, then the webpart, and on page 2, enter the ID we copied earlier.


The refresh is dynamic, so you don’t need to publish the page to see what it looks like!
There’s no save button, simply close the panel.

The results are now scoped to those 2 site collections, and below is an overview 😋



Happy customization!



5 Responses to “Custom Search in SPO using Out-of-the-Box features and Open Source Webparts!

  • Joe Volk
    1 year ago

    I have a question for you on the refiners. We have some custom fields in a library and we would like to refine our results on those. I have mapped them to a managed property that can be refined, but I don’t see any of those RefinableString00 type of managed properties in the choice field for a refiner. Thoughts on this?

    • Veronique Lengelle
      1 year ago

      Hi Joe,
      I can think of a few things to check.

      1) Do you have data in your site under that property? For the property to be crawled, it needs to have at least one value somewhere.
      2) Have you configured the Refiners webpart (clicking on “Edit refiners”) by adding RefinableString00 in “Filter managed property”?

      From my experience, once you’ve added (at least) one value in this property, the crawl seems to happen only once a week, and I’ve seen Friday/Saturday evening.

  • Kim Williams
    1 year ago

    I installed the latest package, but it didn’t have Search Results or the Search Pagination webparts.

  • Great content! Super high-quality! Keep it up! 🙂

    • Veronique Lengelle
      2 years ago

      Thanks for the positive feedback, appreciated! 😊

%d bloggers like this: