Pnp-modern-search: Adding Field to Search Filters

Created on 12 Jul 2021  路  10Comments  路  Source: microsoft-search/pnp-modern-search

Version used
Ex: 4.2

Question
I'm trying to add a field that can be used as a filter in the Search Filters Web part. I created two, just need one to work. The first one that I made called Topic was a lookup field from another SP list. It allows multiple selections. It does not show up as an option to add as a filtered field in the Search Filters Web part. I think this is either because that it is a lookup field and/or because it allows for multiple selections.

To test this out, I created a second field called Topic1. This is a choice field (radio buttons) that only allows one selection. I also told SP to index this field. However, it also does not show up as an option in the Search Filters Web part.

My question would be, how do I get custom Document Library fields to be usable in the Search Filters Web part?

Screenshots
topic

Additional context
Thanks!

question v4

All 10 comments

Hi @chasquad,

The filters are based on the search results from the PnP - Search Results Web Part.

First of all, the PnP - Search Filters and PnP - Search Results Web Parts must be linked together. Then, if you want to refine a custom field, ensure that your search schema is configured well. Here some links about the SharePoint search schema:

Basically, once your search schema is configured, you can use the Debug view of the PnP - Search Results to ensure that your new Refinable/Alias is available in the properties of your items.
Don't forget to specify your _Refinable_ into the Selected properties of your PnP - Search Results Web Part.

Let us know if this information helps you :)

I'm probably not understanding all of the steps that may be needed. I added both Topic and Topic1 as managed properties in the Site Collection that are mapped to crawled properties of the same name. I waited a day and they still do show up for the PnP - Search Results properties section nor in the PnP- Search Filters section. When I added these to the site collection search managed properties in SP neither could be selected as "refinable" and maybe that is the problem. That checkbox was grayed out for both Topic and Topic1 managed properties.

@chasquad
Might be this is going to help you.

  • Filter will work on data sources like if you're getting result from Libraray1 for example that choice or lookup column should be present inside that library only.
  • Don't create a fresh Managed property .Use existing one like in your case RefinableString00 or some other properties can help that has refinable enabled by default and map to crawled property you want to.
    image
  • Use that managed property in your filter webpart (pass statically).
  • I think that's enough to work.

Let us know if this information helps you :)

Chasquad,

I had a similar issue, created custom list managed meta data property in my case.

The mapping of ows_fieldname was mapped to managed property in SPO Search Admin at tent level, waited days for update in pnp debug, no result for RefinableString03. I decided to then replicate the mapping in search schema both at tenant level, and site collection administration level, within 15 minutes, pnp debug mode, voila RefinableString03 was showing values....

I've tried so many different avenues now that I think that I need to take a moment and go back and undo everything that I've tried and then start over. I think that I'll start with a Site Column called Topic and then add that Site Column to a document library and populate that data. Then in both tenant admin and site settings add the same (if possible) RefineableText00 and map that to the Site Column? Will the Site Column show up with ows_? And then let it sit and churn for a few days before even trying to add this to the PNP Search Filter and Results web parts?

Yes, example of what I did!

Created site columns, and content type in content type hub, but you can create your site column and content type in your local sure sure collection, I prefer central management of everything.

So, managed meta data in my case, created a column called Entity, managed meta data column, pulling data from term store. I then added to content type and library, populated library with data.

Waited a day, then checked crawled property entitled ows-entity, then I had mapped to RefinableString03 example, at tenant level, then also at site collection level.

Next day, I checked search box and searched for entity:then value, also RefinableString03:value.

Try this, and yes I would start again.

It is as simple as that I have mentioned.
Create on Tenant level and also reindex your search on site collection level under search offline option.
Same problem I was facing and it work on first go. 馃槉

The only issue I have, not sure if you come across. You're aware title is not sortable, therefore I tried to map ows_title to a RefinableStringXX managed property, reindex, crawled, waited, nothing.....no joy.

It's all good having pnp search to build solutions, but business need to order by title in ascending...

I've removed everything, that I can remember, that I tried out. I then created a new Site Column (different name than before), add it to the Document Library, populated that data, added the RefineableString01 to both the site collection and tenant search, and initiated the reindexing of the site collection search. Now I wait until Monday to check it out!

Hopefully this work and I thank everyone for your help!

This worked. Thanks so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RedGlow picture RedGlow  路  5Comments

jimmywim picture jimmywim  路  4Comments

MarcoSimon picture MarcoSimon  路  5Comments

sympmarc picture sympmarc  路  5Comments

fijaz picture fijaz  路  3Comments