Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Find first level child using query

Avatar

Level 5

Hi

I am trying to find the child pages for the content path provided, I am using the below parameter to find the pages :

path=/content/geometrixx/en/toolbar type=cq:Page orderby=@jcr:content/cq:lastModified

This giving me all pages below toolbar also the childs of child like

But i want only at first level and not above account, Any idea how to add criteria in query debugger to find only child page of the path selected.

Thanks

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

If you are not required to use a query, I would use the API and use somthing like this; it is much faster than a query.

Page p = ... Iterator<Page> iter = p.listChildren();

(see https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/wcm/api/Page.html#listChildren%28com.day.c...)

View solution in original post

4 Replies

Avatar

Correct answer by
Employee Advisor

If you are not required to use a query, I would use the API and use somthing like this; it is much faster than a query.

Page p = ... Iterator<Page> iter = p.listChildren();

(see https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/wcm/api/Page.html#listChildren%28com.day.c...)

Avatar

Level 5

Jörg Hoh wrote...

If you are not required to use a query, I would use the API and use somthing like this; it is much faster than a query.

  1. Page p = ...
  2. Iterator<Page> iter = p.listChildren();

(see https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/wcm/api/Page.html#listChildren%28com.day.c...)

 

 

 

Thanks Jorg, I want to use query not because only to list children, I need to some other operation to apply on the resultset, like i want to get the child pages in sorted order & may be some more filters can be added.  I have made changes in my original post, please suggest if you can provide me the parameters to be use in query debugger.

Avatar

Employee Advisor

Hi

First of all, there is variant of the listChildren() method available, where you can specify a filter. But this method does not support ordering, in that case you need to do it yourself.
I am not really familiar with the querybuilder,  but if you use JCR SQL2 directly, you could use something like this:

SELECT * FROM [cq:Page] AS s WHERE ISCHILDNODE(s,'/content/geometrixx/en/toolbar') order by [jcr:content/cq:lastModified]

kind regards,
Jörg

Avatar

Level 1

You can use path.flat=true in your query string to get only the direct children.

  • path : This is used to search under a  particular hierarchy only.
    • path.self=true : If true searches the subtree including the main node given in path,  if false searches the subtree only.
    • path.exact=true : If true exact path is matched, if false all descendants are included.
    • path.flat=true If true searches only the direct children .