Hi
I guess, Join of two group work for you:-
Please have a look at the link[1] shared by Scott:-
[1] http://aemcq5.blogspot.in/2014/11/cq5-querybuilder-simplified.html
//
Lets make of join of two groups in this example. This is a tricky one and need understanding regarding the predicates and filters in CQ5 querybuilder.
When we try to create two group, we can assign separate paths and type at the group level. This is known as filtering predicate. All the xpath predicates need be same in this case otherwise if we apply the group level ORing separately using p.or = true, the execution time of such a query will be prohibitively long.
Let's look at below query:
1_group.1_group.path=/content/geometrixx/en
1_group.2_group.path=/content/dam/geometrixx
1_group.p.or=true
2_group.1_group.type = cq:Page
2_group.2_group.type = dam:Asset
2_group.p.or=true
3_group.2_group.fulltext = marketing:interest/product
3_group.2_group.fulltext.property = @jcr:content/cq:tags
3_group.1_group.1_group.fulltext = marketing:interest/product
3_group.1_group.1_group.fulltext.property = @jcr:content/metadata/cq:tags
3_group.1_group.2_group.fulltext = marketing:interest/services
3_group.1_group.2_group.fulltext.property = @jcr:content/metadata/cq:tags
3_group.1_group.p.and=true
3_group.p.or=true
This will find all the nodes with either type cq:Page or dam:Asset and tagged with cq:tags at the same hierarchy from jcr:content.Also note that we are applying 2 tags match for the asset tags. It is important to remember that group level ORing for path and type along with same set of properties will work relatively fast.
We can screw up the execution of above query if we do ORing for say group1 by doing following:
group.1_group.p.or=true.
This will result in a very inefficient and long executing query. Beware of such cases and implement the same logic in business layer by using separate queries and combining result rather than using the same one.
I hope this will help you.
Thanks and Regards
Kautuk Sahni
Kautuk Sahni