Subscribe via RSS Feed Connect with me on LinkedIn

Adding Search Refiners in SharePoint 2010

[ 28 ] June 17, 2010 |

The new search refinement panel in SharePoint 2010 search is pretty cool! When you fire up a search you can see the various pieces of metadata that match the search results and then drill down from there.

But what if you want to add your own? Well its actually very easy if the column type that you want to add is Managed Metadata. If you are adding other columns types you have to do it the old SharePoint 2007 way where you have to crawl the property, create a managed property, do the mapping and then add the XML into the Refinement Panel.

But if the column is a Managed Metadata column then the SharePoint search engine will actually create managed properties out of the crawled properties for you so you don’t even have to do that! So all you need to do is add the following xml to Refinement Panel Filter Category Definition XML file:

Add the following to the Filter Category Definition file

So the XML is below:

<Category Title="Field Name"  Type="Microsoft.Office.Server.Search.WebControls.TaxonomyFilterGenerator" MappedProperty="ows_MetadataFacetInfo" MoreLinkText="Show More"
MetadataThreshold="1" NumberOfFiltersToDisplay="5"/>

Ok there are a bunch more options that you can add but put simply you need the following:

  • Title: This is the name of the Column or Field that the Managed Metadata is mapped to. If the field has a space that’s ok but remember its the column name
  • Type: This has to be the TaxonomyFilterGenerator for Managed Metadata fields (for other fields you use the ManagedPropertyFilterGenerator class)
  • Mapped Property: For Managed Metadata fields this is ALWAYS ows_MetadataFacetInfo, SharePoint will do the rest!

You can actually have a look at the default Filter Definition Configuration file and see that there it two Categories defined in this exact fashion: Managed Metadata Columns and Tags. The difference between the two is that Tags is the Enterprise Keywords while Managed Metadata Columns are used for well Managed Metadata Columns! So if you want to force or create your own refiners follow the steps above and you should be all good!

More Links

Need more information about the refinement panel, try these links:

Tags: , ,

Category: General, How To

About Michal Pisarek: Michal Pisarek is the founder of Dynamic Owl Consulting and a Microsoft SharePoint MVP. View author profile.

Comments (28)

Trackback URL | Comments RSS Feed

  1. [...] This post was mentioned on Twitter by Hire SharePoint Dev, Michal Pisarek. Michal Pisarek said: How to manually add search refinements in #sharepoint #sp2010 http://bit.ly/bqmgai [...]

  2. [...] If you wish to use choice fields in Search Refiners then you must manually configure the Managed Property and then add the option to the Refinement Panel [...]

  3. Dallas says:

    Great info! However, I’m unable to add a refiner if the column name has a space in it, have you made this work?

  4. keren says:

    Hi,
    great info that i realy need for my customer!
    what about managed metadata columns that have spaces in the name? i didn’t succedd to display them.
    what determines the syntax of Title=”Field Name” – is that the name of the managed metadata or the name of the column in the content type which uses that managed metadata (in case they have different names)?
    thanks,
    keren

  5. Hmm interesting about the space issue…

    Let me have a look and I will see if I can look into this, it could be that instead of using the actual column name it might be using something else to create the refinement… stay tuned folks!

  6. Juran says:

    Hi Guys,

    I need some help with the advanced search in Sharepoint 2010. I need to switch off the document text so that it does not search the content of the doc but only the title, filename and metadata.

    Regards

    Juran

  7. Achini says:

    Hi,

    I am using Fast Search for Sharepoint. For one refiner category (say “owner” ), I can see only 100 refiner elements. But it should return more than that. Is there any parameter I should change to get all refiner elements ?

  8. Hi Juran,
    I don’t know if this is possible however when you perform an advanced search and specify metadata then you are effectively only searching on the metadata.

  9. Hi Achini,
    Have you changed the Accuracy Index to more than 100 so that it calculates the refiners correctly?

  10. [...] left hand refinement menu (although slight adjustments may be necessary to the properties of the refinement panel web [...]

  11. Kevbo says:

    Great article!
    I was able to get a custom refiner to show up in the search results. However when I try to click any of the options under the custom refiner category, it just states no entries were found even though there are a bunch.

    To clarify:
    I have a custom column called “Document Status” that is a choice field with ‘Draft, Review, Final and Archive’ as the options. I can get this to show up in the refinement panel and even show counts next to them.

    However when I click on any of them, it just says no items found. Also if I click any other refiner (like Result Type or author) and then try clicking on one of my “Document Status” refiners, I get an error stating ‘Your query is malformed. Please rephrase your query’….

    I checked the link and it seems to be passing all the right variables so I’m not sure why this is happening. I’ve ran a full and incremental crawl a bunch of times as well. I may try trimming down some of the options that I entered for the refinement panel since I just copied one of the other refinement options.

    I’ll post back if I can find out how to fix it but let me know any ideas. thanks :)

  12. Kevbo says:

    Wahoo! Gotta love google :)
    I’ve found the answer to my issue and will explain but here is the link that let me to the light.

    http://blogs.msdn.com/b/spnext/archive/2010/08/09/customising-sharepoint-2010-search-refiners.aspx

    Basically I found that when you create a mapped property for search, you have to make sure you map it to the crawled property. These are the properties that have ‘ows_’ before the name. So I had to skip over the normal ‘Document Status’ property and select the ‘ows_Document_2x00Status’ property for mapping. Once I did that and ran a full crawl the refiner was working properly :)

  13. Hey Kevbo!
    Good work on figuring out your problem.
    You are correct, for non managed metadata fields you have to use the same process as you did in SharePoint 2007 which is to create a managed property from a crawled property and then perform the configuration in the refiner web part.

  14. [...] If you wish to use choice fields in Search Refiners then you must manually configure the Managed Property and then add the option to the Refinement Panel [...]

  15. Ehsan says:

    Guys i am facing a problem,

    I have managed metadata and i am using it on the picture library and also on the list library,

    My search refiners only showing the managed meta data assosicated with picture library but not from the list library,

    I am in urgent need of the solution. thanks

  16. Hey Eshan,
    There could be many reasons for this. Can you provide a bit more information about your scenario?

    Is this managed metadata that you are using?
    How many items are tagged?
    Is the metadata the same across the picture and list libraries?

  17. shakir says:

    Sorry i mis-write my name earlier.
    Thanks for your prompt response mate

    Please read my answers below.

    Is this managed metadata that you are using?
    Yes,

    How many items are tagged?
    I have a detailed list in which i am using these terms as managed metadata columns,

    Is the metadata the same across the picture and list libraries?
    Yes the some of the terms are being used across the pictures and list libraries.

    One thing more, i am facing the same problem of field with space in it, those fields arent appearing in the search refiner

  18. shakir says:

    One thing more,
    it doesnt search even i fill the space with _x0020_

    waiting for your prompt response mate!

  19. Steve says:

    I struggled to get fields with a space in the name working. The answer is to use “x0020″ e.g. “Documentx0020Type”. I found the answer here http://underthehood.ironworks.com/2011/05/sharepoint-2010-choose-your-managed-metadata-search-refinements.html

  20. Shaqayeq says:

    hi there!
    Thank you vey much for usefull info, but i have a problem. I wanna add a refiner for site titles instead of URLs. In editing the xml file for Title I use “Web Title” and for mappedProperty “siteTitle” that exists in the managed properties.
    This shows the name of sites in the refinement panel, but using them I don’t get a correct result.
    Does anybody know what else I should do?
    Thanks in advance.

  21. Berney says:

    Great article and replies! Is there a way to order the refinements? I want to specify one of my metadata fields to be the first refinement listed. It seems to pick its own order and ignore the order in the xml.

    Berney

  22. Berney says:

    One more question. If I have a list and a library with mostly different metadata. I am putting together a search results page which displays results from both. The two have one metadata field in common. Is there a way to get the key filter to talk to both search result webparts on the common term and only one of the search result webparts in the other?

    Berney

  23. Berney,
    Yep you can control the order of the refinements, they will get generated in the same order as they are defined in the XML file.

    For the webpart question I doubt if you can get that working to be honest..

  24. Josh Noble says:

    Great post Michal. If any of your readers need help connecting the dots between your posts on the search refinement panel, I have posted a video walkthrough at the link below that covers creating custom refiners, displaying counts, and adjusting the accuracy index.

    http://surfray.com/resources/webcasts/408-customizing-search-refiners-in-sharepoint-2010-pt1.html

    Josh Noble

  25. shaik din says:

    How can i make refiners for custom results page am not using oob search.

  26. Nishanth says:

    Hi Shaqayeq,

    even i have the same problem as yours.
    can you please let me know if you had a solution for this.

    Thanks

  27. James says:

    Michal, once again great article definitely helped me through doing this for SharePoint 2010.

    Great comments aswell as I had an issue with adding a ManagedMetadata field with spaces.

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.