Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

querybuilder groups

Avatar

Level 4

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

2 Replies

Avatar

Community Advisor

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

Avatar

Community Advisor

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')

]



Arun Patidar