Add Taxonomy filed in SharePoint search refinement web part
My first attempt to add taxonomy terms in a refinement web part on a classic search results page did not produce a human readable refiner so I decided to create a post about that. Following my intuition and what I tough is the way to make it work, I initially tried to add the auto generated by SharePoint search managed property owstaxIdTermSetProperty (ows_taxid_TermSetProperty) to the refinement web part. The display values in the refiner were the actual metadata with term Ids that is not really user readable.
After maybe 3 hour search on how to add taxonomy set to a refiner, I was able to find only one good post. This is why I created mine, so I can come back to it in case I ever forget about that.
How to add human readable terms in SharePoint search refinement web part
This is a brief tutorial with pictures on how to add existing term set to the refinement web part. In short, we will have to change the search schema of the site collection where the taxonomy terms are used in a form of a taxonomy fields populated with data in lists. We will have to map the human readable crawled property ows_TermSetProperty (not ows_taxid_TermSetProperty) to a RefinableString property in the site collection search schema. Again it is important to understand that the search schema of the site witch the taxonomy fields and data belongs to will be modified, not the Enterprise Search site schema or any other sitecolleciton search schema.
Change the search schema of the site collection that has the taxonomy data
Go to the site collection where the terms data resides. Go to the site settings
If you cannot find such button in the menu, the settings page URL you should access is https://your_tenant.sharepoint.com/sites/your_site/_layouts/15/settings.aspx
Navigate to search schema
Under the managed properties tab, use the managed property filter box and try to find RefinableString.
Select refinable managed property that is not used, in my example is RefinableString00. The refinable will open in a new page at https://xx.sharepoint.com/sites/xx/_layouts/15/managedproperty.aspx?property=RefinableString00&level=sitecol
Navigate down to the "Mappings to crawled properties" section and add your taxonomy field there.
Use the find box to find your Taxonomy crawled property:
Go at the bottom of the page and to save. You can see that is it mapped when you go back to the screen with the mapped properties.
Change search refinement web part to show the taxonomy terms
Now, let's go to the search results page and configure the web part to use our RefinableString01 as topic refiner.
Go to your search results page, typically at ~sitecollection/pages/results.aspx.
Edit the refinement web part on the page.
Find and select the RefinableString01 managed property from the list.
If the data against the new mapping RefinableString01 is already indexed by SharePoint search. We will get that little nice preview:
Here is the final refiner result and my human readable taxonomy values.
Possibly the crawler has not yet indexed the data, in case you do not get the little preview.
Note, the refiners are dynamic, if there are not search results on the page showing content with the taxonomy included then the refiner would not be visible on the page as well.
It is not obvious how to map human readable taxonomy terms in SharePoint refinement web part. We have to modify the search schema of the sitecolleciton so we would need site collection admin rights to do that.