Expand my Community achievements bar.

How to get jcr:content of first level child nodes using QueryManager

Avatar

Level 3

I need to get only first level child jcr:content node(`/content/qwe/shows/{showName}/jcr:content` where showName's template is showpage, showpage2 or showpage3)

I use the following config for QueryManager

path=/content/qwe/shows/ path.flat=true 0_property=@jcr:content/cq:template 0_property.1_value=/apps/qwe/templates/showpage 0_property.2_value=/apps/qwe/templates/showpage2 0_property.3_value=/apps/qwe/templates/showpage3

Wich equals to the following `XPATH` wich returns cq:Page nodes:

/jcr:root/content/qwe/shows/* [ (jcr:content/@cq:template = '/apps/qwe/templates/showpage' or jcr:content/@cq:template = '/apps/qwe/templates/showpage2' or jcr:content/@cq:template = '/apps/qwe/templates/showpage3' ) ]

How to configure QueryManager to generate the following query to get cq:PageContent nodes:

/jcr:root/content/qwe/shows/* [ (jcr:content/@cq:template = '/apps/qwe/templates/showpage' or jcr:content/@cq:template = '/apps/qwe/templates/showpage2' or jcr:content/@cq:template = '/apps/qwe/templates/showpage3' ) ]/jcr:content
2 Replies

Avatar

Level 10

When searchign for nodes at a specific level - I find JCR SQL better option. You can select the exact level. For example:

String sql= "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '"+path +"/%' AND NOT jcr:path LIKE '"+path +"/%/%'";

Avatar

Level 3

We use query manager, because generated query is much more bigger. I just show part of it