Skip to main content
akhilraj
Level 5
April 28, 2022
Risolto

Query builder for different Property

  • April 28, 2022
  • 2 risposte
  • 1096 visualizzazioni

Hi Team,

I am writing a query,

 

path=/content
type=cq:Page
1_property=@jcr:content/category_id
1_property.value=%54ceab56-c3b6-44c7-ae3f-08fc87af9045%
2_property=@jcr:content/category_parent_id
2_property.value=%54ceab56-c3b6-44c7-ae3f-08fc87af9045%
p.limit=-1

 

The requirement is to get all pages with either jcr:content/category_id  or jcr:content/category_parent_id =54ceab56-c3b6-44c7-ae3f-08fc87af9045 . But it is giving zero results eventhough there are multiple pages, What will be the issue in query?

Questo argomento è stato chiuso alle risposte.
Migliore risposta di Anmol_Bhardwaj

The requirement is to get all pages with either jcr:content/category_id  or jcr:content/category_parent_id =54ceab56-c3b6-44c7-ae3f-08fc87af9045 

 

As you stated, the requirement is to have OR. But what your query does is apply the AND function.

You need to use the group.p.or=true in your query.

Something like this : 

path=/content
type=cq:Page
group.p.or=true
group.1_group.1_property=@jcr:content/category_id
group.1_group.1_property.value=%54ceab56-c3b6-44c7-ae3f-08fc87af9045%
group.2_group.2_property=@jcr:content/category_parent_id
group.2_group.2_property.value=%54ceab56-c3b6-44c7-ae3f-08fc87af9045%
p.limit=-1

Query Reference : https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md 

2 risposte

lukasz-m
Community Advisor
Community Advisor
April 28, 2022

Hi @akhilraj,

Please try to add like operation. So your query could look like below.

path=/content
type=cq:Page
1_property=@jcr:content/category_id
1_property.value=%54ceab56-c3b6-44c7-ae3f-08fc87af9045%
1_property.operation=like
2_property=@jcr:content/category_parent_id
2_property.value=%54ceab56-c3b6-44c7-ae3f-08fc87af9045%
2_property.operation=like
p.limit=-1

Here are some links that could be useful in the future:

Anmol_Bhardwaj
Community Advisor
Community Advisor
May 2, 2022

The requirement is to get all pages with either jcr:content/category_id  or jcr:content/category_parent_id =54ceab56-c3b6-44c7-ae3f-08fc87af9045 

 

As you stated, the requirement is to have OR. But what your query does is apply the AND function.

You need to use the group.p.or=true in your query.

Something like this : 

path=/content
type=cq:Page
group.p.or=true
group.1_group.1_property=@jcr:content/category_id
group.1_group.1_property.value=%54ceab56-c3b6-44c7-ae3f-08fc87af9045%
group.2_group.2_property=@jcr:content/category_parent_id
group.2_group.2_property.value=%54ceab56-c3b6-44c7-ae3f-08fc87af9045%
p.limit=-1

Query Reference : https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md