Configure Human-Readable Date Facets

Introduction

Goal

Configure human-readable date facets in a faceted tree.

Background

When using a date property as a facet in a faceted navigation, facet values will show as milliseconds since epoch by default. To make date facets understandable for human beings, it is possible to configure date resolutions such as year, month, and day.

Date Resolutions

To specify a resolution for a date facet, add a dollar sign ($) and the desired resolution after the property name in hippofacnav:facets. For example:

myproject:date$year

The following date resolutions are available:

  • year

  • month

  • week

  • dayofyear

  • dayofweek

  • day ( = day of month)

  • hour

  • minute

  • second

The month resolution is 0-based: January is number 0, December is number 11. This is in line with java.util.Calendar.

Example

To enable navigation of news documents (from the out-of-the-box News feature) by publication date, configure a faceted tree as follows:

/content/documents/myproject:
  /faceted-news:
    jcr:primaryType: hippofacnav:facetnavigation
    hippo:docbase: d2b1775c-fb97-4080-bd66-ede4ac874b5a
    hippofacnav:facets: [ myproject:date$year, myproject:date$month, myproject:date$day ]
    hippofacnav:facetnodenames: [ Year, Month, Day ]

The result is a faceted tree as in the example below:

/content/documents/myproject:
  /faceted-news [30]:
    /Year [27]:
      /2015 [1]:
      /2016 [18]:
        /Year [18]:
        /Month [18]:
          /6 [3]:
          /8 [9]:
            /Year [9]:
            /Month [9]:
            /Day [9]:
              /12 [3]:
              /17 [3]:
              /23 [3]:
              /hippo:resultset [9]:
            /hippo:resultset [9]:
          /9 [6]:
          /hippo:resultset [18]:
        /Day [18]:
        /hippo:resultset [18]:
      /2017 [6]:
      /hippo:resultset [27]:
    /Month [27]:
    /Day [27]:
    /hippo:resultset [30]:

Using such a faceted tree, a delivery tier implementation can render a faceted navigation which enables users to narrow their search results down by year, month, and day of the month. It is even possible to render the navigation as a calendar (see Events in the online GoGreen demo for an example).

See Configure a Guided Drill Path in a Faceted Tree to specify a pre-defined order in which the facets become available (for example, only show month after year has been selected).

 

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?