Hello everyone,
I query the JCR with the following query:
String queryString = "SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node,'" + subPagePath + "') AND (NAME() like 'headline%' or NAME() like 'text%' or NAME() like'image%')";
It works as expected but the ordering of the nodes is not like the ordering in crxde. Is there a way to get the elements in the exact same ordering like in crxde?
I want to recreate the structure of a Page and deliver it to another App.
So if there is this structure:
It should be:
Br,
Tim
Solved! Go to Solution.
please check this out Query for fetching assets with the same ordering as used in DAM
If you want to maintain the order, the suggested practice is to use JCR API as opposed to query. It also betters the performance.
querybuilder order by default node order See if this answers your question ??
Views
Replies
Total Likes
You want to move the node structure to another part of the AEM JCR?
Views
Replies
Total Likes
No, I want use the Page content for An mobile App or rss feed. So I need the tree structure of the Page to build a list of content and put it in a differrent HTML Format, json or XML.
So I thought Read out the nodes in the order like it is in the tree and create for example an XML out of it.
Which contains headline, Text and Image Tags. But to recreate a Page in another Page I need to order the Elements. Maybe there is a better way?
Thanks so far.
Views
Replies
Total Likes
JCR API supports ordering nodes -- see JCR 2.0: 23 Orderable Child Nodes (Content Repository for Java Technology API v2.0)
Views
Replies
Total Likes
please check this out Query for fetching assets with the same ordering as used in DAM
If you want to maintain the order, the suggested practice is to use JCR API as opposed to query. It also betters the performance.
I did now change the code to this, but it still orders the nodes unnatural.
map.put("path", "/content/press-releases/2017/2017-aaaa");
map.put("group.p.or", "true");
map.put("group.1_property", "sling:resourceType");
map.put("group.1_property.value", "aaaa/components/content/text");
map.put("group.2_property", "sling:resourceType");
map.put("group.2_property.value", "aaaa/components/content/headline");
map.put("group.3_property", "sling:resourceType");
map.put("group.3_property.value", "aaaa/components/content/image");
map.put("orderby", "@path");
Query query = queryBuilder.createQuery(PredicateGroup.create(map), session);
query.setStart(0);
query.setHitsPerPage(-1);
SearchResult result = query.getResult();
Long sum = result.getTotalMatches();
Iterator<Node> nodes = result.getNodes();
nodes.forEachRemaining(node -> {
try {
String name = node.getName();
} catch (RepositoryException e) {
e.printStackTrace();
}
});
querybuilder order by default node order
QueryBuilder Debugger does not support it because usually you don't have a search when you want the node order. can simply use navigational access (node.getNodes()) in case you want node order.
But then I have the problem again to get all nodes of a branch.
So both solutions are not working...what to do now?
Should I iterate recursively through the nodes?
Views
Replies
Total Likes
Views
Likes
Replies