Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Query JCR to fetch pages based on some conditions

askdctm
Level 9
Level 9


Hi All,

path=/content/www/xx/xx
type=nt:unstructured
1_property=abcd
1_property.operation=exists
2_property=efgh
2_property.operation=exists
3_property=ijkl
3_property.operation=exists
p.limit=-1

We want to retrieve pages, only when a specific component included in a page [there are multiple components having similar properties] has these properties(abcd,efgh & ijkl).

The above query when run in http://localhost:4502/libs/cq/search/content/querydebug.html is not working as per our requirement.

Can someone please tweak this query to meet our requirements.

Any thoughts will be really helpful.

1 Accepted Solution
smacdonald2008
Correct answer by
Level 10
Level 10

Read this article - there are different ways in which to query JCR. Also - use the AEM Query tool to experiment with different query searches: /crx/explorer/ui/search.jsp.

http://cq-ops.tumblr.com/post/23544023402/how-to-query-cqs-jcr-with-sql-or-xpath

I found this tool to be very useful

View solution in original post

7 Replies
ANKUR_CHAUHAN
Level 2
Level 2

Is there anything unique for this component?

if yes then use that property in your search query or you can use sling:resourceType property with the default value of your component i.e. /apps/abc/components/xyz. then it will return the result with all nodes having this property. ex - 

/content/geometrixx-outdoors/en/activities/nairobi-runners-running/jcr:content/par/product_reference... 

Iterate this result set &  split each URL on the basic of /jcr:content then first part will be the page URL.

ANKUR_CHAUHAN
Level 2
Level 2

type=nt:unstructured
path=/content/xyz
1_property=cq:commerceType
1_property.operation=exists
2_property=productData
2_property.operation=exists
3_property=cq:isCancelledForChildren
3_property.operation=exists

 

I am using this query for finding all nt:unstructured node having properties "cq:commerceType, productData, cq:isCancelledForChildren". this query is working fine and returns expected result. If you are not able to find it working then do the debugging by using one by one condition & check results.

askdctm
Level 9
Level 9


Hi Ankur,

Thank you for your reply.

I added sling:resourceType property and the modified query as below, But still it doesnt seem to be working.

path=/content/xxx/xx/xx
type=nt:unstructured
1_property=sling:resourceType
1_property.value=x/x/x/x/x
2_property=abcd
2_property.operation=exists
3_property=efgh
3_property.operation=exists
4_property=ijkl
4_property.operation=exists
p.limit=-1

Your thoughts on this will be really helpful.

askdctm
Level 9
Level 9


Hi Ankur,

Thank you for your reply.

The query is working fine for me. But the problem is I want to find only pages which has a specific component which has these properties.
There are many components with same properties and I do not want those to come up in results.

smacdonald2008
Correct answer by
Level 10
Level 10

Read this article - there are different ways in which to query JCR. Also - use the AEM Query tool to experiment with different query searches: /crx/explorer/ui/search.jsp.

http://cq-ops.tumblr.com/post/23544023402/how-to-query-cqs-jcr-with-sql-or-xpath

I found this tool to be very useful

View solution in original post

gcarlino
Employee
Employee

Hi

Could you elaborate what sort of result you get? Too much? Not at all?
How much time does it take to the query to render the results?

askdctm
Level 9
Level 9

Hi Carlino,

Nope, It did not throw up any results.