8

How to sort/filter search result in Sitecore SXA by __created date or __updated date to retrieve recent search items

4

Create facet item

  1. Navigate to your site facets node /sitecore/content/tenant/site/Settings/Facets
  2. Add new item using following template /sitecore/templates/Feature/Experience Accelerator/Search/Settings/Facets/DateFacet
  3. Fill field name with the name of the field stored in index. (In my case it will be movie_released as I am showing you configuration from my example site)enter image description here

Add rendering to a page

  1. Open page where you want to display results
  2. Add Search Results rendering (will be used to display sorted results)
  3. Add Sort Results rendering. When adding create new data source item for it (template: /sitecore/templates/Feature/Experience Accelerator/Search/Datasource/SortingGroups).
  4. Next create your filter configuration items under datasource created above. You can do it in CE. enter image description here

Fields:

  • Title - used for displaying purposes
  • Facet - select your date facet that you create in step 1.
  • Direction - there are two directions: ascending and descending. Normally you create two option items for a single facet, on for asc. and another for desc. order.

Summary

Once you configure everything properly you should be able to sort your results using different drop down options. See example: enter image description here

If you are new to SXA you can learn how to use different renderings from XA.Reference. I created a reference site which shows how to configure every rendering in SXA. It is standard Sitecore package with example site inside.

Latest release supports SXA 1.2

https://github.com/alan-null/XA.Reference/releases

  • 1
    It works properly when i am creating facet with my custom date field but its not working with __created and __updated date field facet. Thanks for your valuable time – mahboob May 22 '17 at 9:19
  • 1
    Make sure that the name of the field is valid (it is not always the same as field name taken from Sitecore item). For fields you are trying to use it will be: __smallcreateddate, __smallupdateddate. You will find those field definitions in configuration. – Alan Płócieniak May 22 '17 at 10:29
2

To be able to sort by date you have to create a facet for your date field. Then you can use that facet as a default sort order in the Sort Results rendering. You can also use Sort Results rendering.

  • It works properly when i am creating facet with my custom date field but its not working with __created and __updated date field facet. Thanks for your valuable time – mahboob May 22 '17 at 9:20
  • 1
    Ensure that you are using proper case of letters, those fields are called __Created and __Updated. – Dawid Rutkowski May 22 '17 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.