Date Range predicate search problem | Community
Skip to main content
Level 2
October 16, 2015
Solved

Date Range predicate search problem

  • October 16, 2015
  • 3 replies
  • 3880 views

Hi,

I am trying to execute search using date range properties on a particular node, CQ5.5. I have created the XPATH query successfully and is given below:

//element(*, nt:hierarchyNode)

[

(jcr:contains(jcr:content/@sling:resourceType, 'mohegansun/components/page/eventpromotionsdetailpage') and

jcr:contains(jcr:content/event_par/event/@dropdown, 'promotion ')) and

(((@jcr:content/event_par/event/end >= xs:dateTime('2013-08-26T23:59:59.637Z')) or (@jcr:content/event_par/event/recurrence/rule/until >= xs:dateTime('2013-08-26T23:59:59.637Z'))))

]/rep:excerpt(.) order by jcr:content/event_par/event/@end

(predicate tree):
ROOT=group: limit=6, excerpt=true, offset=6[
    {group=group: or=false, and=true[
        {0_fulltext=fulltext: relPath=jcr:content/@sling:resourceType, fulltext=mohegansun/components/page/eventpromotionsdetailpage}
        {1_fulltext=fulltext: relPath=jcr:content/event_par/event/@dropdown, fulltext=promotion }
    ]}
    {type=type: type=nt:hierarchyNode}
    {3_group=group: [
        {group=group: or=true[
            {1_path=path: path=/content/poconodowns/en/events-and-promotions/promotions}
        ]}
    ]}
    {tags=tagid: tagid=null, property=jcr:content/cq:tags}
    {orderby0=orderby: sort=asc, orderby=@jcr:content/event_par/event/end}
    {6_group=group: [
        {group=group: or=true[
            {0_daterange=daterange: lowerBound=2013-08-26T23:59:59.637Z, property=jcr:content/event_par/event/end, lowerOperation=>=}
            {1_daterange=daterange: lowerBound=2013-08-26T23:59:59.637Z, property=jcr:content/event_par/event/recurrence/rule/until, lowerOperation=>=}
        ]}
    ]}
]

When i am trying to run this query on CRXDE, its giving me correct results. Though if i run it from Query Debugger it doesn't give me any results only provide number of hits and same is the case with java code (QueryBuilder API).

Can anyone please point out what i am doing wrong here?

I have gone through http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/search/eval/DateRangePredicateEvaluator.html documentation but didnt fully understand its limitations (Does DateRange not support ORing of fields? or it cannot work with path filter predicate at all?)

Any pointers would be helpful.

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ojjis

I have used the following predicate in the java for the Query Builder, 
I have the date-range and the path in there, can that be of any use ?
 

/* Some code.. */ HashMap<String, String> map = new HashMap<String, String>(); map.put("path", MY_PATH); map.put("type", "nt:unstructured"); map.put("property", "sling:resourceType"); map.put("property.value", MY_RESOURCE_TYPE); map.put("group.p.or", "true"); // combine this group with OR map.put("group.1_fulltext", "*" + this.searchTerm + "*"); map.put("group.1_fulltext.relPath", "@mycomponent/jcr:description"); map.put("group.2_fulltext", "*" + this.searchTerm + "*"); map.put("group.2_fulltext.relPath", "@mycomponent/jcr:title"); map.put("group.3_fulltext", "*" + this.searchTerm + "*"); map.put("group.3_fulltext.relPath", "@mycomponent-content/text"); map.put("group.4_fulltext", "*" + this.searchTerm + "*"); map.put("group.4_fulltext.relPath", "@mycomponent-text/jcr:title"); map.put("group.5_fulltext", "*" + this.searchTerm + "*"); map.put("group.5_fulltext.relPath", "@mycomponent-title/jcr:title"); map.put("orderby","@mycomponent/start"); map.put("p.limit", MY_LIMIT); map.put("relativedaterange.property","mycomponent/start"); map.put("relativedaterange.lowerBound", "-1d"); /* the rest... */

/Johan

3 replies

Ojjis
Level 7
October 16, 2015

Hmm, thats strange.
You should be able to work with multiple daterange properties like such:

map.put("daterange.p.or","true"); map.put("daterange.1_property","@jcr:content/event_par/event/recurrence/rule/until"); map.put("daterange.2_property","@jcr:content/cq:lastModified"); map.put("daterange.lowerBound", myLowerDate.toString()); 

Would that work? Try to add some predicates at a time and see when it stops working to pinpoint the problem.
Let me know how it goes

/Johan

Ojjis
OjjisAccepted solution
Level 7
October 16, 2015

I have used the following predicate in the java for the Query Builder, 
I have the date-range and the path in there, can that be of any use ?
 

/* Some code.. */ HashMap<String, String> map = new HashMap<String, String>(); map.put("path", MY_PATH); map.put("type", "nt:unstructured"); map.put("property", "sling:resourceType"); map.put("property.value", MY_RESOURCE_TYPE); map.put("group.p.or", "true"); // combine this group with OR map.put("group.1_fulltext", "*" + this.searchTerm + "*"); map.put("group.1_fulltext.relPath", "@mycomponent/jcr:description"); map.put("group.2_fulltext", "*" + this.searchTerm + "*"); map.put("group.2_fulltext.relPath", "@mycomponent/jcr:title"); map.put("group.3_fulltext", "*" + this.searchTerm + "*"); map.put("group.3_fulltext.relPath", "@mycomponent-content/text"); map.put("group.4_fulltext", "*" + this.searchTerm + "*"); map.put("group.4_fulltext.relPath", "@mycomponent-text/jcr:title"); map.put("group.5_fulltext", "*" + this.searchTerm + "*"); map.put("group.5_fulltext.relPath", "@mycomponent-title/jcr:title"); map.put("orderby","@mycomponent/start"); map.put("p.limit", MY_LIMIT); map.put("relativedaterange.property","mycomponent/start"); map.put("relativedaterange.lowerBound", "-1d"); /* the rest... */

/Johan

Level 2
October 16, 2015

Hello guys,

I have also got a requirement where I need to OR two different date range properties: jcr:content/cq:lastModified for cq pages and jcr:content/jcr:lastModified for dam assets.

Did you do anything that can help me in following?

    map.put("pagedaterange.property", "jcr:content/cq:lastModified");

    map.put("pagedaterange.lowerBound", lastModified );

    map.put("assetdaterange.property", "jcr:content/jcr:lastModified");

    map.put("assetdaterange.lowerBound", lastModified );