• Home
  • /Archive
  • /Modify the Search Refinement Panel in SharePoint Without Code

Modify the Search Refinement Panel in SharePoint Without Code

SharePoint

The goal of this exercise is to add/modify the refinement panel web part on a search results page in SharePoint 2010.  No code required.  Keep in mind that customization of the OSSSearchResults.aspx page is unsupported. So in my example, I created a Search Center site, and pointed my contextual search to the Search Center. This way I can customize the search results page.

Step 1 – Create Site Column

Create a site column(s) in the site where the items that will use the property are stored.  In my case I created a lookup column to a list that returned the Title of the list item called Entity Lookup.

Step 2 – Add Site Column and Map to Content

Next we need to create a document library and Add an Existing Site Column.  It is not required to add the column to content types, but this will provide the ability to edit the column in Edit Properties modal dialogue window.  Be sure that you have a number of items that use this property and have a value added or the refinement will not show up with the search results.

Step 3 – Perform a Full Crawl

I will explain why we do this in the next step.  You may be able to do an incremental crawl, but the first time I tried it, this did not work.  After that, I just did a full crawl for good measure.  Obviously in production, you may have to wait until the next crawl to proceed.  To do this go to Central Admin->Manage Service Applications->Search Service Application->Content Sources->Drop Down the Content Source and say Start Full Crawl.
startfullcrawl

Step 4 – Verify Crawled Property and Add Managed Property

First verify that after the crawl, the column(s) that were added are listed as a crawled property.  To do this go to Central Admin->Manage Service Applications->Search Service Application->Metadata Properties->Crawled Properties.  In the search box type in “ows_[column name]” and click find.  The result will depend on what type of column created and how long the name is.  If it is a multi-word column name, just use the first word in the search. In my case the crawled property is ows_Entity_x0020_Lookup.

ows

Initially, there will be no value in the Mapped To Column.  Once you verify that the Crawled Property Exists, select Managed Properties link at the top of the page.

Choose New Managed Property.  Give it a name and a type.  In my case I call it Entity and give it type Text.  Next choose Add Mapping:

map

Search for the Crawled Property you just verified and click ok.  I set the following options on the managed property and then click ok to create it.

prop

Step 5 – Perform another Full Crawl

See Step 3.

Step 6 – Modify Refinement Panel

In my case I created a Search Site in the same site collection as the documents, but as long as the Search Page has access to the scopes that this content lives you are ok.  The other advantage to a Search Site is that the Search page is already built and linked up.  On the search page, click Edit Page.  Then Edit the Search Refinement Web Part.

panel

In the web part properties, chose Refinement.  Click the ellipses on Filter Category Definition.
filter
This will open a less than optimal view of the XML that makes up the definition.  The element for a new refinement looks like this:
code
My code element looks like this:
code2
Take your code for each element add it in the XML after the Filter Categories Tag.  My XML File looks like this:
code3
Finally, make sure to uncheck the Use Default Configuration check box.  This took me a minute to figure out, so save yourself the trouble and uncheck it.
Click OK to close the Web Part Properties screen.
default
Then refresh the page.  Now depending on where you put the code within the web part, you should see your new refinement options.
search
I hope to play with customizing the search page some more.  I will definitely add more posts like this as I do.

9 thoughts on “Modify the Search Refinement Panel in SharePoint Without Code

  1. Thank you for the feedback. I am heads down in some MOSS projects and a MOSS to 2010 conversion, so I am hoping I will get some good content to post soon from that.

  2. It's only on a Site Collection setting I believe. Site Actions->Site Collection Settings->Search Settings-> Site Collection Search Center

    This way you direct custom search scopes. If you want to change the Search Results Page for "This Site" change from OSSSearchResults to your page, but remember you will have a little extra work to pass it the scope.

  3. Hi there, nice post. well, How to display managed properties that have hierarchical relationships? Say property "Location" have "Departments". After user select location, departments for that location should be displayed in refinement panel.

    Thanks
    Khushi

  4. The best solution for heirarchical metadata is more than likely managed metadata within SP2010. However, if you do not use managed metadata, but just columns, then the heirarchy will take care of itself as you filter. The filters will only show up if there are enough results to filter. If you list Location first and Departments second, then with no filter all Locations and all Departments will show. If you choose a location, then the Departments will automatically reduce their result set to those Departments within the selected Location. Make sense?

  5. Hey this is great. I have a weird issue where I am using a people refinement web part but it displays the normal refinement web part categories? Ever seen this before? I add in location, etc and is still just shows site, modified date, etc as if I am searching documents and not people?


Leave a Reply

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

*