简体   繁体   English

我在Adobe CQ5中的情况将是什么查询

[英]What will be the Query in my situation in Adobe CQ5

Root contains one folder, named pending of type sling:folder . 根目录包含一个文件夹,名为sling:folder类型的待定

That have numbers of nodes of nt:unstructured type, having name of long value, that long value is very important for my code processing. 具有nt:unstructured类型的节点数,名称为long值,该long值对我的代码处理非常重要。

Now I want to get top 20 nodes(20 minimum node name , ie, long value) data from this pending folder. 现在,我想从该挂起的文件夹中获取前20个节点(最小20个节点名称,即long值)的数据。

Can you tell me how can I write the JCR query for this situation ? 您能告诉我如何针对这种情况编写JCR查询吗?

Edit No. 1 编辑1号

Repository repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));

// Obtain the query manager for the session via the workspace ...
QueryManager queryManager = session.getWorkspace().getQueryManager();    
// Create a query object ...

String expression = "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/pending])";
Query query = queryManager.createQuery(expression, javax.jcr.query.Query.JCR_SQL2);

// Execute the query and get the results ...
QueryResult result = query.execute();

// Iterate over the nodes in the results ...

NodeIterator nodeIter = result.getNodes();

But it gives some order , different than the order present in root node. 但是它给出了一些顺序,与根节点中存在的顺序不同。 But that is not in sort form. 但这不是排序形式。

Edit No.2 编辑2号

Now I got the functionality of this function. 现在,我获得了此功能的功能。 And it working fine now. 而且现在工作正常。 The thing that I got is order the node just above the destination node, that is mentioned in second parameter of this function. 我得到的是将节点排序到目标节点的正上方,这在该函数的第二个参数中已提到。

But the nodes that is coming is of different names(a number). 但是即将到来的节点具有不同的名称(一个数字)。 So how can I sort this using orderBefore . 因此,如何使用orderBefore对此进行orderBefore Because everytime we are not able to know the right location(destination Relative Path) where we have to put this node. 因为每次我们都无法知道必须放置此节点的正确位置(目标相对路径)。

You probably don't need a query for this, if you have structure such as 如果您具有以下结构,则可能不需要查询:

/pending/1
/pending/2
...
/pending/999

you can just iterate over the nodes using the JCR Node's getNodes() method, which returns a NodeIterator. 您可以使用JCR Node的getNodes()方法遍历节点,该方法返回NodeIterator。

A sling:orderedFolder node type for "pending" gives a predictable ordering of the child nodes. 用于“挂起”的sling:orderedFolder节点类型给出了子节点的可预测顺序。

In general, using the tree structure instead of queries is more efficient in JCR. 通常,在JCR中使用树结构代替查询会更有效。

Note also that if you're using Jackrabbit having more than about 10'000 child nodes on the same parent can lead to performance issues. 还要注意,如果您使用的Jackrabbit在同一父节点上有大约10,000个以上的子节点,可能会导致性能问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM