JCR SQL2 - result query order as in JCR browser
Asked Answered
T

2

5

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.

Tinker answered 7/6, 2013 at 8:54 Comment(0)
D
4

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.

Drolet answered 11/6, 2013 at 10:54 Comment(3)
Thanks a lot @jfranktzius . Do you know if there is any way to do this programmatically for a specific query ?Tinker
I created an issue on Magnolia's JIRA, hoping they will make it default. jira.magnolia-cms.com/browse/MAGNOLIA-5301Dna
In case of Apache OAK, there is no such property as respectDocumentOrder. See also: experienceleaguecommunities.adobe.com/t5/…Unction
T
3

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.

Tighe answered 7/6, 2013 at 16:3 Comment(1)
I think you're correct: there is no way to specify the "natural order" as you call it. I will mark your answer as correct for now unless proven wrong.Tinker

© 2022 - 2024 — McMap. All rights reserved.