Highlighted

querybuilder groups

vasimakram

11-04-2018

I have multiple nodes with node name abc in AEM repository. For some of the nodes it will have property expirationDate. I need to get all the nodes with node name abc. If in case that node has expirationDate property then exclude all the expired nodes. Is there any query which returns this instead of getting all the nodes then checking each node whether it is expired or not?

adding sample content json :

{

   "jcr:primaryType":"cq:Page",

   "jcr:createdBy":"admin",

   "jcr:created":"Wed Apr 11 2018 17:01:59 GMT+0530",

   "page1":{

      "jcr:primaryType":"cq:Page",

      "jcr:createdBy":"admin",

      "jcr:created":"Wed Apr 11 2018 17:02:16 GMT+0530",

      "abc":{

         "jcr:primaryType":"nt:unstructured",

         "expiration":"2018-04-8"

      }

   },

   "page2":{

      "jcr:primaryType":"cq:Page",

      "jcr:createdBy":"admin",

      "jcr:created":"Wed Apr 11 2018 17:04:15 GMT+0530",

      "abc":{

         "jcr:primaryType":"nt:unstructured",

         "expiration":"2018-04-10"

      }

   },

   "page3":{

      "jcr:primaryType":"cq:Page",

      "jcr:createdBy":"admin",

      "jcr:created":"Wed Apr 11 2018 17:04:41 GMT+0530",

      "abc":{

         "jcr:primaryType":"nt:unstructured",

         "expiration":"2018-04-25"

      }

   },

   "page4":{

      "jcr:primaryType":"cq:Page",

      "jcr:createdBy":"admin",

      "jcr:created":"Wed Apr 11 2018 17:05:07 GMT+0530",

      "abc":{

         "jcr:primaryType":"nt:unstructured"

      }

   }

   "page5":{

      "jcr:primaryType":"cq:Page",

      "jcr:createdBy":"admin",

      "jcr:created":"Wed Apr 11 2018 17:05:07 GMT+0530",

      "abc":{

         "jcr:primaryType":"nt:unstructured"

      }

   }

}

In this example current date is 2018-04-11 (YYYY-MM-dd). page1/abc and  page2/abc nodes are expired. Output should have

page3/abc

page4/abc

page5/abc

Thanks in advance.

Regards,

Vasim

Replies

Highlighted

Veena_Vikram

MVP

03-10-2018

You cannot check a property value against currentdate using query builder. You might have to get the nodes with the espirationDate set and then filter those which is expired

I think Arun gave the right answer

Highlighted

Arun_Patidar

MVP

03-10-2018

Below is the query for QueryBuilder Debugger

Query

path=/content/

type=nt:unstructured

nodename=abc

daterange.property=expiration

daterange.lowerBound=2018-04-10

p.limit=-1

XPATH Query

/jcr:root/content//element(*, nt:unstructured)

[

((@expiration > xs:dateTime('2018-04-10T00:00:00.000+05:30'))
and fn:name()
= 'abc')

]