Date Range Custom Refiner

Recently, I had a project where a group wanted to show an aging report using SharePoint’s search capabilities. The easiest way to accomplish this is the use of refiners, but I struggled with this quite a bit until I figured out that the left argument of the custom value must ALWAYS be less than the right argument. Here was my final refinement XML markup:

 <Category Title="Aging" Description="Aging groups for items based on the submission date"
  Type="Microsoft.Office.Server.Search.WebControls.ManagedPropertyFilterGenerator"
  MetadataThreshold="3" NumberOfFiltersToDisplay="5"
  MaxNumberOfFilters="0" SortBy="Custom" ShowMoreLink="True"
  MappedProperty="SubmitDate" MoreLinkText="show more"
  LessLinkText="show fewer">
    <CustomFilters MappingType="RangeMapping" DataType="Date"
    ValueReference="Relative" ShowAllInMore="False">
      <CustomFilter CustomValue="0-30 Days">
        <OriginalValue>-30..0</OriginalValue>
      </CustomFilter>
      <CustomFilter CustomValue="30-60 Days">
        <OriginalValue>-60..-30</OriginalValue>
      </CustomFilter>
      <CustomFilter CustomValue="60-90 Days">
        <OriginalValue>-90..-60</OriginalValue>
      </CustomFilter>
      <CustomFilter CustomValue="60-90 Days">
        <OriginalValue>-120..-90</OriginalValue>
      </CustomFilter>
      <CustomFilter CustomValue="120+ Days">
        <OriginalValue>..-120</OriginalValue>
      </CustomFilter>
    </CustomFilters>
  </Category>

This is part of a much larger application that has several search customizations, but you could use this with any out of the box managed properties dealing with dates.

If you want more details on custom refiners, check out Michal Prisarek’s Custom Refinement Filters in SharePoint 2010 Overview. This is a great overview of custom refiners and was one of my jumping off points for this project.

Advertisements

5 thoughts on “Date Range Custom Refiner

  1. I personally blog also and I’m posting a thing comparable to this particular post, “Date
    Range Custom Refiner | SharePoint Dev Notes” ocomp .
    Would you care in cases where Iapply a number of of your own tips?
    Thanks for your effort ,Jillian

      1. Hi can we create multiple surveys in a single survey list?
        How to display all the questions of a survey in a page provided with a feedback button?
        Please respond to my question…..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s