5
votes

I use an application where we can manipulate JCR nodes, typically you would rename, remove, delete, or else move them.

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

I would like to be able to do the same using the JCR SQL2 queries. I have not found anything about this & now start to believe this is not possible.

For instance, if I have a JCR tree such as:

parentNode
|_childNode1
|_childNode2
|_childNode3
|_childNode4

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

I look in those docs 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

Thanks in advance


EDIT: if using Java for your search is an option, you might want to look at Recursive search in JCR repo via java

Probably NOT the most efficient though, so mind the performance hit.

2

2 Answers

4
votes

Did you try setting the property "respectDocumentOrder" to true in your Jackrabbit Search Configuration ?

If true and the query does not contain an 'order by' clause, result nodes will be in document order. For better performance when queries return a lot of nodes set to 'false' (In 1.5 'false' is now the default).

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

2
votes

The only way to specify the order of the query results is to use an ORDER BY clause in your query. If you don't, the implementation is free to return the nodes in whatever order it wants.

But I know of no way in JCR-SQL2 to specify the "natural order" (my term) of child nodes under a parent.