Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

How to sort the component like in CRXDE when query customization?

Avatar

Level 1

I want to query the components and sort the result by the index which like in CRXDE.

But I got the results sorted by the "lastModified" property.

In source code, I didn't put the "orderby" property in the query map.

queryMap.put("path", pagePath); queryMap.put("type", "cq:Page"); queryMap.put("1_property", "jcr:content/cq:template"); queryMap.put("1_property.1_value", OfferUtil.OFFERS26_TEMPLATE); queryMap.put("1_property.2_value", OfferUtil.OFFERS8_TEMPLATE); queryMap.put("2_property", "jcr:content/redirectTarget"); queryMap.put("2_property.operation", JcrPropertyPredicateEvaluator.OP_NOT); queryMap.put("orderby","whichProperty"); // set to get all Offers. queryMap.put("p.offset", "0"); queryMap.put("p.limit", "0");

And I want to know which property can be filled in the map that the result can sorted by the index.

like "index", "order" etc.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Usually you don't have a search when you want the node order and can simply use navigational access (node.getNodes()) in that case.

In Jackrabbit/CRX you can globally configure "respectDocumentOrder" [0] for the query index, which is turned off by default, since it is expensive. It would have effect on queries w/o any order by statement (and might only affect xpath & sql). There is no explicit order by document order statement at all.

[0] http://wiki.apache.org/jackrabbit/Search

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Usually you don't have a search when you want the node order and can simply use navigational access (node.getNodes()) in that case.

In Jackrabbit/CRX you can globally configure "respectDocumentOrder" [0] for the query index, which is turned off by default, since it is expensive. It would have effect on queries w/o any order by statement (and might only affect xpath & sql). There is no explicit order by document order statement at all.

[0] http://wiki.apache.org/jackrabbit/Search