JCR SQL2 - the order of the query result, as in the JCR browser

I use an application in which we can manipulate JCR nodes, usually you have to rename, delete, delete or move them.

Using the JCR API, I can access the nodes in my repository and return the set of nodes in the same order as in the JCR.

I would like to be able to do the same with SQL2 JCR queries. I did not find anything about this and now I am beginning to believe that this is impossible.

For example, if I have a JCR tree, for example:

parentNode |_childNode1 |_childNode2 |_childNode3 |_childNode4 

When querying using JCR SQL2, it returns them in an order different from: childNode1, childNode2, childNode3, childNode4

I look in these documents among others: http://docs.jboss.org/jbossdna/0.7/manuals/reference/html/jcr-query-and-search.html#jcr-sql2-query-language http: // www .day.com / specs / jcr / 2.0 / 6_Query.html

Thank you in advance


EDIT : if you use Java for your search, you can look at Recursive search in the JCR repository via java

Probably NOT the most efficient, so be aware of performance.

+4
source share
2 answers

Have you tried setting the property "respectDocumentOrder" to true in Jackrabbit Search Configuration ?

If true and the query does not contain an order by clause, the result nodes will be in document order. For best performance, when queries return many nodes set to false (in 1.5, false is now used by default).

You should set it to true only if you need it, because the query results will be completely iterated in Java to sort them.

+4
source

The only way to specify the order of the query results is to use the ORDER BY in the query. If you do not, the implementation will be free to return nodes in any order.

But I do not know how to specify in JCR-SQL2 the "natural order" (my term) of child nodes under the parent.

+2
source

Source: https://habr.com/ru/post/1484998/


All Articles