JCR SQL2 - result query order as in JCR browser

谁都会走 提交于 2019-11-28 04:56:10

问题


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.


回答1:


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:


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.



来源:https://stackoverflow.com/questions/16980029/jcr-sql2-result-query-order-as-in-jcr-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!