The Case of the Case-Sensitive CustomFilter Refiner

While working on a project involving setting up FAST Search Server 2010 for Sharepoint, I ran into trouble setting up a custom date refiner. I was hoping to see refiner values that said things like ‘Last 30 Days’, ‘Last 60 Days’, and ‘Earlier’, but instead I saw this, which is the date ranges for the last 30 days, last 60 days, etc.

This is a problem, because it’s much harder to quickly grasp what the different groups are. Which is easier, to understand ‘Last 30 days’ or ‘From 2012-08-12 to 2012-09-12’? Considering that most of the date range is not visible, this makes it even harder to consume. I wanted to fix this.

Refiners

Let’s back up a little. What is a refiner?

In this screenshot, you can see that I searched for ‘shoe.’ On the left-hand side, ‘Shoe Size’ is a refiner, because it allows me to narrow down, or ‘refine’, the search results that I see.

FAST Search for Sharepoint has this same capability. On the search results page, there is a ‘Refinement Panel’ web part, which has a ‘Filter Category Definition’ property in the ‘Refinement’ section of the Web Part properties.

NB: If you customize anything here, be sure to uncheck the ‘Use Default Configuration’ checkbox, or it will ignore whatever you put in.

The ‘Filter Category Definition’ propery contains XML that defines what refiners to show on the search results page. I had a property called ‘Published’, which was a date field, and I was able to get the refiner to appear, but I was hoping to see refinement such as ‘Last Week’, ‘Last Month’, etc. Instead, this is what I saw:

I double and triple checked the XML I had written, and everything looked perfect. I even copy and pasted the XML from the built in date refiner, which uses the ‘write’ property, and it still didn’t display properly.

lower case

After much pain and agony, I decided on a whim to try to use the lowercase version of the property - that is, I put ‘published’ in, instead of ‘Published’, even though everything else in FAST refers to the property as ‘Published’. Here is what I ended up with:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<Category Title="Published" Description="When the item was published" Type=
"Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"
MetadataThreshold="1" NumberOfFiltersToDisplay="6"
SortBy="Custom" ShowMoreLink="False"

MappedProperty="published"

ShowCounts="Count" >

<CustomFilters MappingType="RangeMapping" DataType="Date"
ValueReference="Relative" ShowAllInMore="False">

<CustomFilter CustomValue="Past 24 Hours">
<OriginalValue>-1..</OriginalValue>
</CustomFilter>
<CustomFilter CustomValue="Past Week">
<OriginalValue>-7..</OriginalValue>
</CustomFilter>
<CustomFilter CustomValue="Past Month">
<OriginalValue>-30..</OriginalValue>
</CustomFilter>
<CustomFilter CustomValue="Past Six Months">
<OriginalValue>-183..</OriginalValue>
</CustomFilter>
<CustomFilter CustomValue="Past Year">
<OriginalValue>-365..</OriginalValue>
</CustomFilter>
<CustomFilter CustomValue="Earlier">
<OriginalValue>..-365</OriginalValue>
</CustomFilter>
</CustomFilters>
</Category>

Et Voila, it worked! This was the proper result I was expecting:

The moral of the story is that when you’re setting up managed properties in FAST Search for Sharepoint, be sure to use lowercase versions of the property name everywhere. Otherwise you could run into strange problems.

References:
http://msdn.microsoft.com/en-us/library/ff625183.aspx
http://www.todd-carter.com/post/2010/04/05/expanding-the-refiners
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/03/15/get-to-know-the-refinement-web-part-in-sharepoint-2010-enterprise-search.aspx