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
BedrockMission!

Learn More

View all

Sign in to view all badges

AEM - Adding date range in QuerybuilderAPI

Avatar

Avatar
Validate 1
Level 1
P_Vishnu
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
P_Vishnu
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
P_Vishnu
Level 1

24-08-2020

I have the below query I am using in /libs/cq/search/content/querydebug.html to check the results

 

1_property=test 1_property.value=active 2_property=status 2_property.value=worked p.hits=selective p.limit=-1 path=/home/users type=rep:User

 

This is working and i am getting results .Now I need the records who has a property registrationCompletedDate = 2020-08-09 to know the users registered on 9th.

Can someone help how I can add this date range in my query?

I tried this, but did not work

 

daterange.upperBound=2020-08-10
daterange.lowerBound=2020-08-9
daterange.property=registrationCompletedDate

 

AEM querybuilder

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

511 likes

Total Posts

647 posts

Correct Reply

213 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

511 likes

Total Posts

647 posts

Correct Reply

213 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile
Vijayalakshmi_S
MVP

24-08-2020

Hi @P_Vishnu,

Given that we are looking for exact match on a Date property, we can bring in the search results with "property" predicate itself instead of Date related predicates like daterange/relativedaterange/dateComparsion where first two works on range and last works on comparison of two Date type properties.

Try the below sample query and let know if it works

To bring in all pages which has property of type "Date" + name "registrationCompletionDate" + value like 2020-08-09 (in jcr:content of page)

path=/content/we-retail
type=cq:Page
property=@jcr:content/registrationCompletionDate
property.value=2020-08-09% // assuming Time is different and date is 2020-08-09
property.operation=like

Answers (2)

Answers (2)

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

24-08-2020

Assuming that the property "registrationCompletedDate' in with rep:User node, the query should be similar to 

path=/home/users
type=rep:User

daterange.property=registrationCompletedDate
daterange.upperBound=2020-08-19T23:59:59.000-04:00
daterange.lowerBound=2020-08-19T00:00:00.000-04:00

p.limit=-1

 

Now, you need to have an index for registrationCompletedDate, it should be similar to

- compatVersion = 2
- async = "async"
- jcr:primaryType = oak:QueryIndexDefinition
- evaluatePathRestrictions = true
- type = "lucene"
+ indexRules
+ rep:User
+ properties
+ registrationCompletedDate
- name = "registrationCompletedDate"
- propertyIndex = true

 

 

berliant_0-1598301950572.png

 

berliant_1-1598302015327.png

 

 

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

24-08-2020

Check this sample:

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