Expand my Community achievements bar.

SOLVED

Search and limit the depth of search

Avatar

Level 3

Hi,

I want to use query builder to search the siblings of a page node in CQ. For this what i am doing is to get the parent of the page, then use that in the path attribute of the predicate and run the search. But this search is not only returning me the siblings of the page but it is also returning me the child page nodes of the siblings. I tried using p.nodedepth but that did not help.

Can you suggest me how I can achieve this? Let me give an example:

Lets us assume this is my node structure: 

a

    1, 2, 3

b

    1,2,3

c

    1,2,3

 

Here a, b, c are siblings and 1,2,3 are children of the siblings. I should not get the children in the results and I should get only a,b and c in the result.

This is the predicate i use:

path=/content/B2B_HC/en_US/specialties-catalog/
type=cq:Page
p.hits=full
p.nodedepth=1

 

Is there something wrong here?

Regards,

Yadhu

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hiya, just a thought. Is there a reason you need to search for it ?
 

<% Iterator<Page> pageChildren = myPage.listChildren(new PageFilter(request)); %>

 

would work in just the same way that you want your search to do it and it would be less to write as well.
Regards 
/Johan

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

Hiya, just a thought. Is there a reason you need to search for it ?
 

<% Iterator<Page> pageChildren = myPage.listChildren(new PageFilter(request)); %>

 

would work in just the same way that you want your search to do it and it would be less to write as well.
Regards 
/Johan

Avatar

Level 2

What Johan has said above is right. If you still want to use search query then you can something like this using xpath query :

/jcr:root/content/geometrixx/en/element(*, cq:Page)