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.

orderby aem6.1

Avatar

Level 2

We are facing an issue with sorting using the query builder API in AEM 6.1.

We have a query where sorting happens based on a custom(not cq default) and this does not work at all in AEM 6.1, while sorting with a cq default property works. 

orderby=@jcr:content/newOrder -----> this does not work

orderby=@jcr:content/jcr:title -----------> this works

Has anyone faced this issue earlier or know the fix for this ? Please help.

4 Replies

Avatar

Administrator

Hi 

Please have a look this post:-

Documentation :https://docs.adobe.com/docs/en/aem/6-1/develop/search/querybuilder-api.html

 

Link:- http://stackoverflow.com/questions/21676718/adobe-cq5-jcr-how-to-orderby-sorting-query-builder-resul...

//

map.put("orderby", "@created"); 
map.put("orderby.sort", "desc"); // in case you want it descending
In case you need to check property within a child node, you can provide the relative path to that for the orderby value. For eg., if you are searching for dam:Asset and want to order them based on the jcr:lastModified property of its metadata, then your query would be something similar to this.

map.put("path", "/content/dam/geometrixx");
map.put("type", "dam:Asset");
map.put("orderby","@jcr:content/metadata/jcr:lastModified");

Link:- http://adobeaemclub.com/multiple-order-by-clause-querybuilder-in-aem-aka-cq5/

For Query Builder Tutorial:- https://hashimkhan.in/aem-adobecq5-code-templates/query-builder/

I hope this would help you.

Thanks and Rehards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 2

Hi Kautuk,

Thanks for your reply. But I think you got my question wrong. I am aware of how the orderby predicate works :)

Let me re-phrase my issue.

This query works well in 6.0. The issue is with 6.1 only.  

Avatar

Level 10

Hi,

orderby works fine in AEM 6.1 with custom property, i remember using it recently in one implementation. Not sure if its a bug as I was having SP1 installed and worked perfect

Can you share complete query or make sure generated xpath query is proper.

Thanks