Friday 8 August 2014

How to create Search filters in SharePoint

The subject of this post is something I find comes up often with clients and is a driver for them to really understand Content Types.  What isn't covered is building or structuring Content Types and an assumption is made that you already have these built and defined.

So the scenario is that we have multiple Content Types with different tagging and we want to use that in our Search Centre.  For this example I have a Trader Portal with a variety of company documents and five different Content Types.  Some of the terms span multiple Content Types which is common when defining taxonomy.

So ultimately we start with a library containing multiple Content Types and Columns with documents:


This library will grow over time and may span multiple libraries with the same Content Types so ideally I want one search experience for these documents.  Once documents have been indexed by Search we can find them amongst all our content under everything, but the metadata doesn't appear help us with our search.

In my example I have created a new page in our search centre called documents and restricted the results web part to only return documents from the index. But in order to configure the metadata appearing as filters we need to access the admin console and configure the search schema.  As I am using this with SharePoint Online the search options are limited but we still have the schema option available.


Go in to the Search Schema and the next steps involve finding and configuring some of our Search Refiner values that SharePoint has prepared for us.  There are different types of refiners for integers, dates and strings but I commonly find strings is used for our metadata.  To find these search for a managed property and click to open a value which hasn't been configured.

 
Click to open the RefineableString00 and you will see a screen where pretty much everything is greyed out.  The only real configuration we can do is to map this to a property string.  So scroll down to the 'Mappings to crawled properties' and click to add a mapping.
 
 
Occasionally now the pop up will appear at the top of the page and involves you scrolling up so if this happens just go back to the top and then search for your value.  In my example I want to add a content type column called client so I search using this word.  It will then return three properties for client and we are interested in the 'ows_client' value.  I have configured four values and each time they use the 'ows_???' option as the other two return results are not useful for filtering.
 
 


We now have our property mapped to a schema value so once we are happy save the change and come out of our schema refinablestring by clicking ok.  In our schema table we should now search and see that our refinablestring is matched to our crawled property.  You can see I have configured four values for my search centre.


At this point we have to wait for our next search crawl for these to fully take effect but we can go back to our search centre page and start looking at the filtering.  From the new documents search page we discussed earlier or from the everything page I can now edit and then edit the filtering web part.

So now I am editing the refinement web part:


And from the web part properties page choosing the refiners:


We now have refinement choices so we can add and remove our refinements.  As we have mapped properties to schema fields these can be added in easily now and configured.  We may also want to add in a refiner for Content Type which may seem simple from the choices.  But for this we don't use the 'ContentType' option but instead the 'SPContentType' option to show our fields and add it across.


For my example I created four refinablestrings and plan to use the spcontentype to aid filtering.  So I remove all the filters expect for LastModfiedTime and instead add in spcontentype, refineablestring00, refineablestring01, refineablestring02 and refineablestring03.  This means that my results now offer me some relevant refinements for the documents returned.


Also ensure when you add each refinement that configuration is completed.  At the minimum ensure the Display name field is complete so that users can relate to the values displayed.

Once all refinements are configured then save and publish the page.  To test they all return values it is often best to use the * wildcard to return all results.  This will then show your refinements and as for example you choose a content type then the refinements change to only show values for that content type.

Very clever and very powerful when configured against content in SharePoint and my example also shows how having an additional tab in Search for documents aids findability.


This process isn't restricted to document and can be used for metadata on pages or for values assigned to a user profile and that you want appearing on the people search page.   I suggest you now try and configure from this guide in a test environment.  As I mentioned clients love seeing custom refiners associated to their business.

No comments:

Post a Comment