With 7.2 onwards sitecore went fancy and provided a lot of cool options for search with facets within sitecore content editor. It does include a lot of options and facets but what if you want to search an item with date field?
Well you will guess I should be able to pick up the “Search by a Field Value” from the Search Filters and it should just work for me. If you think that is true then unfortunately it is not correct.
Here are the steps you need to follow in order to allow the Sitecore to search a date field value.
- Goto the /sitecore/system/Settings/Buckets/Search Types/Start Date and copy paste it to /sitecore/system/Settings/Buckets/Search Types/User Defined
- Rename it to match it to your date field. In my example i am going to make it to Resource Spotlight Start Date
- Update below values in the field to make sure it searched for your field and not the start field.
- In above image 1 is to change the icon in the search interface.
- 2 is must for changing it to your desired field name. It does not need to be your exact field name but something unique to indicate user.
- 3 is for field. Here you should put your actual field name. If you have doubts on what is your exact field name then open the LUKE and then find your field’s name. In my instance my field name under template was Resource Spotlight Start Date but under LUKE it was resource_spotlight_start_date.
- 4 is for control type parameters and that can be same as your name too.
- 5 is for Displaying text for your user.
- Ok so once you do this you will see nice shiney field created by you in the search interface.
- now when you click it you will observe that it gives you calendar search.
- But if you select it and hit run it wont give you any results. WHY????
- Well you need to do this one last step goto your app_config/include and find the file Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config.
- Open the file and add this lines
<field fieldName="resource_spotlight_start_date" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.DateTime" format="yyyyMMddTHHmmZ" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider"> <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" /> </field>
- Under the <fieldNames> section. This ensures that your master index and lucene consider your newly created field to be date searchable.
- Once you add this close your config, rebuild indexes and search again from step 11.
- Boom you will see below results.