Query Build API - Results in random order

Avatar

Avatar
Validate 10
Level 2
v1101
Level 2

Likes

4 likes

Total Posts

150 posts

Correct reply

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

Avatar
Validate 10
Level 2
v1101
Level 2

Likes

4 likes

Total Posts

150 posts

Correct reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile
v1101
Level 2

30-07-2020

Hello Community - Currently I am using query Builder API to fetch the results from JCR.

 

One query using sort by on lastModified date  and other requirement is to return the "results in random order (I don't mention any orderby here)" when I query JCR, both the options gives me the results in same order. Could you please tell me how to fetch the results by lastModified date.

 

Below is the query that I am using for OrderBy

path=/content/xx/en/yy/test
1_property=sling:resourceType
1_property.value=yycomponents/page/abc
1_property.operation=like
orderby=@jcr:content/cq:lastModified
orderby.sort=desc

p.limit=50

 

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 250
MVP
ChitraMadan
MVP

Likes

273 likes

Total Posts

165 posts

Correct reply

67 solutions
Top badges earned
Boost 250
Establish
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Boost 250
MVP
ChitraMadan
MVP

Likes

273 likes

Total Posts

165 posts

Correct reply

67 solutions
Top badges earned
Boost 250
Establish
Ignite 1
Give Back 5
Give Back 3
View profile
ChitraMadan
MVP

31-07-2020

Hi @v1101 ,

 

The Only property that you need to change in your query is the orderby as highlighted below:

 

path=/content/xx/en/yy/test
1_property=sling:resourceType
1_property.value=yycomponents/page/abc
1_property.operation=like
orderby=@cq:lastModified
orderby.sort=desc

p.limit=50

 

The reason fo this is, the query will return the paths till jcr:content and then the query was checking cq:lastModified in jcr:content/jcr:content/cq:lastModified and hence it was not working.

With above change, it should work fine.

Hope this helps!!

Answers (2)

Answers (2)

Avatar

Avatar
Give Back 5
Employee
vanegi
Employee

Likes

392 likes

Total Posts

378 posts

Correct reply

148 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile

Avatar
Give Back 5
Employee
vanegi
Employee

Likes

392 likes

Total Posts

378 posts

Correct reply

148 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back 10
Give Back
Boost 50
View profile
vanegi
Employee

30-07-2020

You can try something like:

 

fulltext=we-retail
group.p.or=true
group.1_p.and=true
group.1_path=/content
group.1_type=cq:Page
group.1_relativedaterange.property=jcr:content/cq:lastModified
group.1_relativedaterange.lowerBound=-1M

 

OR 

 

1
2
3
type=cq:Page
orderby=@jcr:content/cq:lastModified
orderby.sort=desc



Please check https://helpx.adobe.com/in/experience-manager/6-3/sites/developing/using/querybuilder-api.html for more details. Thanks!!

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

03-08-2020

Try to create your query in below format.

 

path=/content/we-retail
type=cq:Page
1_property=jcr:content/sling:resourceType
1_property.value=weretail/components/structure/page
1_property.operation=like
orderby=@jcr:content/cq:lastModified
orderby.sort=desc