Have you ever wanted to create a refinement web part that uses the year instead of the entire date? The default date refiner uses last day, week, month, six months, and year for its intervals. There is no default year refiner. This post will show you the steps to create the custom date refiner.
Step 1: Create a new Site Column
- Navigate to site setting > Site Columns > Create
- Give the column a name
- Select Calculated for the type of column
- Select a group
- Input the following in the formula field: =YEAR([Modified]) (see Figure 1)
*Note: You can use “Created” instead of Modified if you want to refine by the year created instead of the year the document was modified.
Step 2: Run a full crawl
Step 3: Map managed property to the crawled property
- Click Site Settings>Search Schema
- Find an unused RefinableString managed property and select edit property
- Scroll down to Mappings to crawled Properties
- Click Add Mapping
- Map the managed property to the crawled property ows_Example, where “Example” is the name you gave the calculated site column
- Click OK
Step 4: Run a full Crawl
- Navigate to the page that will contain the refinement web part
- Click Edit Page
- Select the Web and Click Edit Web Part
- Select Choose Refiners
- From the list of Available Refiners, add the RefinableString managed property that you mapped to the crawl property (see Figure 2).
- Enter the name of the refiner in Display name.
- Select the Refinement Item display template
- Select your preference for Sort by, Sort direction, and Maximum number of refiner values.
- Click Okay> Apply>Okay
- Save the Page
- Check in/Publish the Page
Congratulations! You have just created your own date refiner that utilizes the year instead of the entire date.