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.

  1. Goto the /sitecore/system/Settings/Buckets/Search Types/Start Date and copy paste it to /sitecore/system/Settings/Buckets/Search Types/User Defined
  2. Rename it to match it to your date field. In my example i am going to make it to Resource Spotlight Start Date
  3. Update below values in the field to make sure it searched for your field and not the start field.
  4. date-type-search
  5.  In above image 1 is to change the icon in the search interface.
  6. 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.
  7. 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.
  8. 4 is for control type parameters and that can be same as your name too.
  9. 5 is for Displaying text for your user.
  10. Ok so once you do this you will see nice shiney field created by you in the search interface. search
  11. now when you click it you will observe that it gives you calendar search.calendar
  12. But if you select it and hit run it wont give you any results. WHY????
  13. Well you need to do this one last step goto your app_config/include and find the file Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config.
  14. Open the file and add this lines
  15. <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>
    
    
  16. Under the <fieldNames> section. This ensures that your master index and lucene consider your newly created field to be date searchable.
  17. Once you add this close your config, rebuild indexes and search again from step 11.
  18. Boom you will see below results.
  19. resultes

 

Happy searching.

 

 

Advertisements