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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Can QueryBuilder.createQuery can have params as sling:resourceType and orderBy.sort property together?

Avatar

Level 2

Map<String, String> params = new HashMap<>();

params.put(KEY_PATH, path);

params.put("type", "cq:Page");

params.put("orderby", "jcr:content/@cq:lastModified");

params.put("orderby.sort", "desc");

params.put("1_property", "jcr:content/sling:resourceType");

params.put("1_property.value","cq/experience-fragments/components/xfpage");

params.put("p.offset", "0");

params.put("p.limit", "-1");

params.put("p.guessTotal", "1");

Query query = queryBuilder.createQuery(PredicateGroup.create(params), session);

Here I am getting all the pages of type "cq/experience-fragments/components/xfpage" but I am losing the orderby property. Am I doing wrong something here?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You may need to change orderby with below:

params.put("orderby", "@jcr:content/cq:lastModified");

I ran the same query with above changes and I am able to get results in descending order.

Screen Shot 2018-06-19 at 11.09.09 PM.png

Thanks

Arun

View solution in original post

0 Replies

Avatar

Correct answer by
Community Advisor

You may need to change orderby with below:

params.put("orderby", "@jcr:content/cq:lastModified");

I ran the same query with above changes and I am able to get results in descending order.

Screen Shot 2018-06-19 at 11.09.09 PM.png

Thanks

Arun

Avatar

Level 2

Thanks Arun. It helped.

params.put("orderby", "@jcr:content/cq:lastModified");  is the correct way.