Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

JCR query datetime issue

kevingtan
Level 4
Level 4

Hi All,

Has anyone dealt with timestamp ordering issue with multiple timestamps?

For instance, we have the following query:

/jcr:root/content/my-site//element(*,cq:PageContent)[@sling:resourceType='event-page' and (@datestamps >= '2018-05-01')] order by @datestamps descending

Supposed we have a few results returned and some of them have multiple entries for datestamps

event1 [2018-08-01],

event2 [2018-02-01, 2018-07-01, 2018-12-01] (repeating event)

event3[2018-06-01]

...

the results will be in the order of event1, event3, event2. As long as at least one of the datestamps is later than 2018-05-01, event2 will match, but then when dealing with sorting, XPath uses the oldest date/timestamp to sort.  Is it possible to use the latest date to sort when dealing with descending?

Thanks,

-Kevin

2 Replies
Shashi_Mulugu
Community Advisor
Community Advisor

Please refer to below link.

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/querybuilder-predicate-referen...

Properties

  • orderby
    either JCR property name indicated by a leading @, for example @jcr:lastModified or @jcr:content/jcr:title, or another predicate in the query, for example 2_property, on which to sort
  • sort
    sort direction, either "desc" for descending or "asc" for ascending (default)
  • case
    if set to "ignore" will make sorting case insensitive, meaning "a" comes before "B"; if empty or left out, sorting is case sensitive, meaning "B" comes before "a"

Use "desc" instead of "descending" and try

kevingtan
Level 4
Level 4

Hi Shashi123,

First of all, the property "datestamps" is not a jcr property, but a customized one, we do not need to have a leading "jcr:" in our case. "datestamps" is a string array holding all dates for the same event. As in our example, there could be an event lasting for a few months. This is a problem to construct a meaningful query because the oldest date is always used when the order is in descending.

By the way, "desc" doesn't work in our case. We are running 6.0, Jackrabbit Oak 1.0.22.