QueryBuilder - multiple daterange properties

Avatar

Avatar
Validate 1
Level 2
Deepikaa_Nagesh
Level 2

Likes

14 likes

Total Posts

46 posts

Correct reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Validate 1
Level 2
Deepikaa_Nagesh
Level 2

Likes

14 likes

Total Posts

46 posts

Correct reply

3 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back
View profile
Deepikaa_Nagesh
Level 2

02-06-2020

Hi,

 

Is it possible to give a regex pattern for a daterange.property in aem query builder and search for all properties falling under the regex pattern.

 

Usecase :  we are trying to query around 30 date properties set for an asset whether if any particular date among them falls under the given date range.

 

Thanks,

Deepikaa

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile
Nupur_Jain
MVP

02-06-2020

Hi @Deepikaa_Nagesh 

 

It is not possible to apply datarange property name as regex. You will have to use group to specify multiple properties like

 

group.1_daterange.property=date1
group.1_daterange.lowerBound=2020-01-01
group.1_daterange.upperBound=2020-02-20

group.2_daterange.property=date2
group.2_daterange.lowerBound=2020-01-01
group.2_daterange.upperBound=2020-02-20

group.p.or=true

 

Change this group.p.or=true/false dependding upon if you want all of them to be in specific range or any one.

 

I know this will create a long query but if you are using query builder in Java, you can loop on array of date property names and creates the predicate conditions like:

 

String datePropertyArray = ["date1", "date2", "date3", "date4"];

for(int number = 0; number < datePropertArray.length(); number++) {

     map.put("group" + number + "_daterange.property", datePropertyArray[number]);
     map.put("group" + number + "_daterange.lowerBound", "2020-01-01");
     map.put("group" + number + "_daterange.upperBound", "2020-02-20");

}

 

Hope it helps!

Answers (6)

Answers (6)

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

484 likes

Total Posts

1,049 posts

Correct reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

484 likes

Total Posts

1,049 posts

Correct reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

02-06-2020

We don't have a regex pattern for a daterange.property but you might have to group it and run the query. 

Avatar

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile
Nupur_Jain
MVP

02-06-2020

Hi @Deepikaa_Nagesh 

 

It is not possible to apply datarange property name as regex. You will have to use group to specify multiple properties like

 

group.1_daterange.property=date1
group.1_daterange.lowerBound=2020-01-01
group.1_daterange.upperBound=2020-02-20

group.2_daterange.property=date2
group.2_daterange.lowerBound=2020-01-01
group.2_daterange.upperBound=2020-02-20

group.p.or=true

 

 

 

Change this group.p.or=true/false dependding upon if you want all of them to be in specific range or any one.

 

I know this will create a long query but if you are using query builder in Java, you can loop on array of date property names and creates the predicate conditions like

 

String[] datePropertyArray = {"date1", "date2", "date3", "date4"};

for(int number = 0; number < datePropertyArray.length; number++) {

     map.put("group" + number + "_daterange.property", datePropertyArray[number]);
     map.put("group" + number + "_daterange.lowerBound", "2020-01-01");
     map.put("group" + number + "_daterange.upperBound", "2020-02-20");

}

 

 

Hope it helps!

Avatar

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

159 likes

Total Posts

370 posts

Correct reply

58 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

159 likes

Total Posts

370 posts

Correct reply

58 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile
Ankur_Khare
MVP

02-06-2020

Did u check this- using groovy script

 

  • daterange : This predicate is used to search a date property range.
    • daterange.property : Specify a property which is searched.
    • daterange.lowerBound :  Fix a lower bound eg. 2010-07-25
    • daterange.lowerOperation : “>” (default) or “>=”
    • daterange.upperBound:  Fix a lower bound eg. 2013-07-26
    • daterange.upperOperation: “<” (default) or “<=”
  • relativedaterange: It is an extension of daterange which uses relative offsets to server time. It also supports 1s 2m 3h 4d 5w 6M 7y
    • relativedaterange.lowerBound : Lower bound offset, default=0
    • relativedaterange.upperBound : Upper bound Offset .
path=/home/users type=rep:User
group.1_daterange.property=jcr:created group.1_daterange.lowerBound=2014-08-18 group.1_daterange.upperBound=2014-08-19
group.2_daterange.property=cq:lastModified group.2_daterange.lowerBound=2014-08-18 group.2_daterange.upperBound=2014-08-19
group.p.or=true

Avatar

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile
Nupur_Jain
MVP

02-06-2020

Hi @Deepikaa_Nagesh 

 

you can not use regex in daterange property, you will have to group multiple dates and apply OR or AND to it. If you are using query builder in Java, you can loop on array of date property names and creates the conditions like:

 

 

String[] datePropertyArray = {"date1", "date2", "date3", "date4"};

for(int number = 0; number < datePropertyArray.length; number++) {
map.put("group" + number + "_daterange.property", datePropertyArray[number]);
map.put("group" + number + "_daterange.lowerBound", "2020-01-01");
map.put("group" + number + "_daterange.upperBound", "2020-02-20");
}

 


Hope it helps!

Avatar

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Establish
MVP
Nupur_Jain
MVP

Likes

165 likes

Total Posts

186 posts

Correct reply

76 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 25
View profile
Nupur_Jain
MVP

02-06-2020

Hi @Deepikaa_Nagesh 

It is not possible to apply datarange property name as regex. You will have to use group to specify multiple properties like

 

group.1_daterange.property=date1
group.1_daterange.lowerBound=2020-01-01
group.1_daterange.upperBound=2020-02-20

group.2_daterange.property=date2
group.2_daterange.lowerBound=2020-01-01
group.2_daterange.upperBound=2020-02-20

group.p.or=true

 

Change this group.p.or=true/false dependding upon if you want all of them to be in specific range or any one.

 

I know this will create a long query but if you are using query builder in Java, you can loop on array of date property names and creates the predicate conditions like:

 

String datePropertyArray = ["date1", "date2", "date3", "date4"];

for(int number = 0; number < datePropertArray.length(); number++) {

     map.put("group" + number + "_daterange.property", datePropertyArray[number]);
     map.put("group" + number + "_daterange.lowerBound", "2020-01-01");
     map.put("group" + number + "_daterange.upperBound", "2020-02-20");

}

 

 

Hope it helps!

Avatar

Avatar
Give Back 50
Employee
berliant
Employee

Likes

207 likes

Total Posts

315 posts

Correct reply

98 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
berliant
Employee

Likes

207 likes

Total Posts

315 posts

Correct reply

98 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
berliant
Employee

02-06-2020

Check if this sample helps:

 

path=/content
type=cq:PageContent
group.p.or=true
group.1_daterange.property=cq:lastModified
group.1_daterange.upperBound=2017-04-21T23:59:59.000-04:00
group.1_daterange.lowerBound=2017-04-21T00:00:00.000-04:00

group.2_daterange.property=jcr:created
group.2_daterange.upperBound=2017-04-21T23:59:59.000-04:00
group.2_daterange.lowerBound=2017-04-21T00:00:00.000-04:00
p.limit=-1

 


/jcr:root/content//element(*,cq:PageContent)[(@cq:lastModified >= xs:dateTime('2015-11-03T04:00:00.000-05:00') and
@cQ:lastModified <= xs:dateTime('2015-11-03T20:00:00.000-05:00')) or (@jcr:created >= xs:dateTime('2015-11-03T04:00:00.000-05:00')
and @jcr:created <= xs:dateTime('2015-11-03T20:00:00.000-05:00')) ]

/jcr:root/content//element(*,dam:AssetContent)[(@jcr:lastModified >= xs:dateTime('2015-11-03T04:00:00.000-05:00') and
@jcr:lastModified <= xs:dateTime('2015-11-03T20:00:00.000-05:00')) or (@jcr:created >= xs:dateTime('2015-11-03T04:00:00.000-05:00')
and @jcr:created <= xs:dateTime('2015-11-03T20:00:00.000-05:00')) ]