adding more than one orderby.sort value to a hashmap

patrikgQD

06-02-2020

I have a predicate map that I am adding a orderby value to and sorting ascending on that field using orderby.sort.
I need to sort ascending on that field, while also adding a "nulls last" sort so that any sortable values will be sorted ascending at the beginning of the list, while all items with a null value in that sortable field will then show up in the list after that. 
How can I accomplish this?
Example:

currentParamMap.put("type", "cq:Page");
currentParamMap.put("orderby", "@jcr:content/publishDate");
currentParamMap.put("orderby.sort", "asc");

I have tried to add a second orderby via 1_orderby and 2_orderby and included the two sort values as 1_orderby.sort "asc" and 2_orderby.sort "nulls last" This does not work for me. I can sort by one or the other, but not both. Can this be done?

Accepted Solutions (1)

Accepted Solutions (1)

Vijayalakshmi_S

MVP

06-02-2020

HI,

 

Query predicate orderby.sort has possible values of "asc/desc" as per - https://docs.adobe.com/content/help/en/experience-manager-65/developing/platform/query-builder/query...

 

If "nulls last" has to be incorporated, then try going for direct JCR-SQL2 and use QueryManager API(javax.jcr.query.QueryManager) for direct JCR-SQL2 query execution.

- javax.jcr.query.QueryManager.createQuery("queryString", Query.JCR_SQL2)

Answers (0)