Using the PnP Modern Search Web Parts with Refiners for Site Name and Content Type

I am a huge fan of the Modern Search Web Parts. They are a perfect bridge from classic search to where we all hope Microsoft Search is heading. The team working on these Web Parts is a first class bunch, and they are doing fantastic work.

I do worry a bit whenever I use these Web Parts, since putting them in place means we are taking on a bit of technical debt. Even if the first party (Microsoft) solutions adopt these exact Web Parts (which I think may well happen), we will at some point need to swap out the open source versions with the first party ones. But these Web Parts provide so much value, I’m willing to recommend using them to our clients.

A very common combination of refiners I see myself using is the Site Name and the Content Type. Between these two pieces of metadata, I know where something lives (which often tells me a lot about whether it matters to me) and what it is. I’ve used these two columns as refiners for years, usually right at the top of the refiner list.

Here’s the quick cheat sheet about how to set them up to work with the Modern Search Web Parts. The documentation for the Web Parts themselves is very good, so I’m not going to try to duplicate the overall steps here: I’ll focus on the Site Name and Content Type refiners.

Believe it or not, the Site Name is not available as a Managed Property we can use as a refiner out of the box. There is a Managed Property called SiteTitle, but it isn’t enabled for use as a refiner.

Because of this, SiteName is usually one of the first Crawled Properties I map to a refinable Managed Property when I’m setting things up in search.

To do this, navigate to the SharePoint Admin Center (yes, you need to be a SharePoint Admin for this – if you aren’t, bake cookies for the person who is). From there, go to More Features / Search / Manage search schema. This is the screen where we can set up the mappings. Type “refinablestr” in the filter box. This will show you the available RefinableStringXX Managed Properties.

Pick the first one which isn’t in use and map the ows_SiteName Crawled Property to it. Here, I’m using RefineableString05. (The number really doesn’t matter, but you need to remember it.)

It’s a good idea to give your RefinableStringXX Managed Property an alias, though it won’t be usable in all situations.

Now you’ve got a Managed Property for the SiteName you can use as a refiner in the Modern Search Web Parts.

Map ows_SiteName to a Managed Property

Luckily, there is already a usable Managed Property for Content Type. I’ve written about this before, as it isn’t all that obvious. The Managed Property you need is SPContentType.

Now you’re ready to add the two Managed Properties to the Modern Search Refiners Web Part. I won’t go through all the possible settings here, as again the documentation is very good. Note that you can change the title for the refiner; here I’m calling SiteName “Project”.

And voila! You have refiners for both the Site Name and Content Type in your Modern Search results.

Happy searching…


Note: Eagle-eyed reader Wes Macdonald (@wesmacdonald) pointed out they renamed the Search Refiners Web Part to Search Filters Web Part to be more consistent with other terminology. Thanks for the correction!

Similar Posts

17 Comments

  1. At Information Leadership, we have been able to add search filters for Team and Channel metadata against every file using our Smart Metadata solution. It is a game changer for find ability with the explosion of Teams in most organizations.

  2. Hi Marc, did you have to change anything in the default refiners to get them to work. I’ve got the v3 modern search solution deployed and its all working. When I add the search filters webpart I cannot get any refiners to show at all and im not sure why.

    The default managed properties should all just work shouldn’t they?

    Thanks
    Anthony

  3. Hi Marc,

    Please ignore my previous comment, i was being a dope not realising you have to connect the search results web part to the filter!

  4. Hi Marc,

    I’m new to SharePoint and I’m a bit lost trying to put together all these components.
    My company doesn’t have any custom refiners and what I need to do is to display a Search Results based on a List and load all documents by default.

    Query Template = {searchTerms}
    ListId:3c0af19d-d52e-4420-81e9-b55e244fdb59
    If its possible to append in here lets say DocType=Procedure

    Result Source ID = LocalSharePointResults

    Default value = *

    So far I’m getting the results I want except that I’m also getting the List Name as first result.

    What I need to do is to be able to have Filters base on my own metadata; lets say Site (Site A, Site B, Site C) and DocType (Policy, Procedure or Training)

    The only filter I’m getting is Date (Creation Date); where should I start to get these refiners loaded by default?

    Is it possible to have a Vertical Tabs showing Policies – Procedures – Training and when the user clicks on any tab we automatically do the filtering based on the DocType?

    I’d really appreciate if you can point me in the right direction.

    Regards,
    Pablo

  5. Hi Marc,

    I have choice field column in sharepoint online site page library, I am trying to add this choice as refiner, I tried to map the crawled property to RefinebleString00 managed property and make sure I have selected Multi option and Refinable property are enabled. Still when I add this property in Search refiner i can see only one of the choice is displaying not the other options.

    Not sure what i am missing here or we cant make Choice field as Refinable property in Sharepoint online?

    Can you please guide me here.

    Regards
    Anand

    1. @Anand:

      It sound like you are seeing the RefinableString00 values in your filters, but maybe not all of them? Which Crawled Property have you napped to the RefinableString00 Managed Property?

      M.

    1. @Chris:

      Sorry for the delay in replying. You can set the sort in the Search Results Web Part on the first property panel (I think in both v3 and v4 – but definitely in v4). There’s an Edit Sort Order button, you could select Created, and decide if you’d like it sorted ascending or descending.

      M.

  6. Hello Marc,

    I followed along this article because this is exactly what I want to do, but for some reason, I am only getting one result from the Site Name refiner I mapped. I followed your instructions to a tee, but for some reason the results I get from the search results web part and the search filters only presents 1 of the over 60k files I have in my tenant. The single result I am getting is the page on which the web part sits. Any suggestions would be very much appreciated.

  7. @Rhett:

    My only guess is you’ve got the search query set up to limit the scope of the search such that you’re only getting the one result. I’d suggest removing any conditions you have there so you’re starting with the 60k files and then add them back in one by one so you get the scope you’d like.

    M.

  8. When i Try to uopdate the Refinablestring00 i got an error:
    The settings could not be saved because of an internal error: Bad request while trying to reach endpoint PUT Call to Setting Type Schema

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.