Expand my Community achievements bar.

SOLVED

Query builder for different Property

Avatar

Level 6

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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 

View solution in original post

2 Replies

Avatar

Community Advisor

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:

Avatar

Correct answer by
Community Advisor

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