Expand my Community achievements bar.

SOLVED

Combine Querybuilder results for multiple queries

Avatar

Level 5

Hello Community - I am looking for the solution to combine the results of below two queries together. If I execute the query-1 and query-2 separately, I get the results but I am looking for the results which include the results from query-1 + query-2. Can someone provide some inputs on this?

 

path=/content/we-retail/us/en/equipment/jcr:content

1_property=sectionPath
1_property.value=%/content/experience-fragments/%
1_property.operation=like

 

2_property=subSectionPath
2_property.value=%/content/experience-fragments/%
2_property.operation=like

 

p.limit=-1

 

Also I am looking for the solution for another query which searches for the multiple paths for the specific property and the results should includes the results from the different paths together.


path=/content/we-retail/us/en/equipment/jcr:content
path=/content/we-retail/us/es/equipment/jcr:content
path=/content/we-retail/ca/fr/equipment/jcr:content
path=/content/we-retail/de/de/equipment/jcr:content
path=/content/we-retail/fr/fr/equipment/jcr:content
path=/content/we-retail/it/it/equipment/jcr:content

 

1_property=sectionPath
1_property.value=%/content/experience-fragments/%
1_property.operation=like

 

p.limit=-1

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @v1101

To bring in all pages which has both property sectionPath and subSectionPath, then using the predicates as is as a single query predicates set should work. 

But if you are looking for pages which has either sectionPath or subSectionPath, then we need to group properties and enable "or". (group.p.or) Something like below

 

path=/content/we-retail/language-masters/en/experience
type=cq:Page
group.1_property=@jcr:content/jcr:title
group.1_property.operation=exists
group.2_property=@jcr:content/cq:tags
group.2_property.operation=exists
group.p.or=true
p.limit=-1

 

 Second, for combining paths, you can use same group concept - group paths and specify "or" as below

 

group.1_path=/content/we-retail/language-masters/en/experience
group.2_path=/content/we-retail/language-masters/es/experience
group.3_path=/content/we-retail/language-masters/de/experience
group.4_path=/content/we-retail/language-masters/fr/experience
group.p.or=true
1_property=@jcr:content/jcr:title
1_property.operation=exists
p.limit=-1
type=cq:Page

 

I suggest to use querydebug.html(http://localhost:4502/libs/cq/search/content/querydebug.html) to execute the predicates which will display its equivalent XPATH query framed in right hand section and will help understand how the conditions are framed 

Vijayalakshmi_S_0-1601665180096.png

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Hi @v1101

To bring in all pages which has both property sectionPath and subSectionPath, then using the predicates as is as a single query predicates set should work. 

But if you are looking for pages which has either sectionPath or subSectionPath, then we need to group properties and enable "or". (group.p.or) Something like below

 

path=/content/we-retail/language-masters/en/experience
type=cq:Page
group.1_property=@jcr:content/jcr:title
group.1_property.operation=exists
group.2_property=@jcr:content/cq:tags
group.2_property.operation=exists
group.p.or=true
p.limit=-1

 

 Second, for combining paths, you can use same group concept - group paths and specify "or" as below

 

group.1_path=/content/we-retail/language-masters/en/experience
group.2_path=/content/we-retail/language-masters/es/experience
group.3_path=/content/we-retail/language-masters/de/experience
group.4_path=/content/we-retail/language-masters/fr/experience
group.p.or=true
1_property=@jcr:content/jcr:title
1_property.operation=exists
p.limit=-1
type=cq:Page

 

I suggest to use querydebug.html(http://localhost:4502/libs/cq/search/content/querydebug.html) to execute the predicates which will display its equivalent XPATH query framed in right hand section and will help understand how the conditions are framed 

Vijayalakshmi_S_0-1601665180096.png

Avatar

Level 5
@ Vijayalakshmi_S Thanks for the prompt response. Appreciate it.

Avatar

Level 2

I am trying this, but unfortunately the results are grouped instead of being sorted across groups by relevance, so items in one group is always first even if the next group has items with a higher relevancy. How do you fix this? Thank you!

Avatar

Level 2

Yeah getting same issue, after query search, results are grouped based on paths. 

For example, if we are having queried for paths /content/us/en & /content/ca/en , then results will have group of pages from /us/en and after that it will have group of pages from /ca/en. Even if we try to sort orderby=@jcr:score , sorting is done for 1st set of pages from /us/en and after that it sorts pages from /ca/en, ideally it should be sorting for entire set of result.