You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Milan Milanov <mi...@null.net> on 2016/07/20 13:48:30 UTC

Child count function in the the query language

Hello there,

I’m trying to order some nodes by how many child nodes they have and i’ve stumped upon a headache.
My query looks like this:

"SELECT * FROM 'nt:hierarchyNode' AS node
WHERE ISCHILDNODE(node, ‘/some/given/path’) 
ORDER BY 'jcr:primaryType' DESC, LENGTH(node) ASC”

This is taking all child nodes of a given node and ordering the nt:folders first (before the nt:files). However, the
LENGTH(node) does not seem to be doing what I want it to do (count the number of children). Is there anything
oak-specific that could solve my problem, like Modeshape’s CHILDCOUNT() or like having a custom function
somehow?

Kind regards,
Milan Milanov

Re: Child count function in the the query language

Posted by Thomas Mueller <mu...@adobe.com>.
Hi,

I'm sorry this feature is not available. You would need to set a property
"childCount" explicitly.

Could you explain the use case please?

Regards,
Thomas



On 20/07/16 15:48, "Milan Milanov" <mi...@null.net> wrote:

>Hello there,
>
>I¹m trying to order some nodes by how many child nodes they have and i¹ve
>stumped upon a headache.
>My query looks like this:
>
>"SELECT * FROM 'nt:hierarchyNode' AS node
>WHERE ISCHILDNODE(node, Œ/some/given/path¹)
>ORDER BY 'jcr:primaryType' DESC, LENGTH(node) ASC²
>
>This is taking all child nodes of a given node and ordering the
>nt:folders first (before the nt:files). However, the
>LENGTH(node) does not seem to be doing what I want it to do (count the
>number of children). Is there anything
>oak-specific that could solve my problem, like Modeshape¹s CHILDCOUNT()
>or like having a custom function
>somehow?
>
>Kind regards,
>Milan Milanov