Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Querybuilder using stream

Avatar

Level 8

Hello Everyone,

 

I have few pages under: /content/abc/us/en  which is having node property:  article value as blog

Now, I need to find out list of pages under:  /content/abc/us/en where  property "article" has the value: blog.

How can I write the query using Java Stream option. Output will be list of pages. i mean List<myPage> = .......

Note: I have sling model: class myPage    which is having the member variables, necessary to hold the page properties.

Can someone, help me to write Querybuilder?

Was searching here: https://kiransg.com/2021/11/22/aem-with-java-streams/

 

Thanks

1 Reply

Avatar

Community Advisor

Hi @Mahesh_Gunaje 
Here is an example of using QueryBuilder in Java to retrieve article pages with a specific property value. You can write the following query, and if needed, you can use Java Streams to filter, map, or transform the results.

Example Query 

path=/content/abc/us/en
type=cq:Page
property=jcr:content/article
property.value=blog
p.limit=-1


Sample Java cpde
https://github.com/arunpatidar02/aemaacs-aemlab/blob/master/core/src/main/java/com/community/aemlab/... 




Arun Patidar