Skip to main content
Keerthi0555
Level 5
Jun 24, 2024 3:05 PM UTC
Solved

Query BUilder

Hi Aem Community,

 

Is it best practice to run query builder under a page like path as page without .html, I need to find specific component of a page.

Thank You,

Keerthi K.

kapil_rajoria
kapil_rajoriaAccepted solution
New Participant
Jun 25, 2024 6:15 AM UTC

Hi @keerthi0555 using the query builder to search for specific components within a page is a common practice. When making query, it is a best practice to use a path that points to the page's content node rather than including the .html extension. It ensures that the query targets the content structure rather than the rendered output.

4 replies

Syed_Shaik
Level 3
Sep 30, 2025 3:54 AM UTC

Hi @keerthi0555,

Go to http://localhost:4502/libs/cq/search/content/querydebug.html

==============================

 

  • path → where you want to search (e.g., /content/your-site).

  • type = nt: unstructured → components are stored as NT: unstructured nodes.

  • property = sling:resourceType → identifies the component type.

  • property.value → the component’s full resourceType (e.g., your-site/components/content/your-component).

  • p.limit = -1 → return all matches (remove the default 10-item limit).

 

===============================

{
"path": "/content/your-site",
"type": "nt: unstructured",
"property": "sling:resourceType",
"property.value": "your-site/components/content/your-component",
"p.limit": -1
}

 

Translate
kautuk_sahni
Employee
Jun 25, 2024 12:18 PM UTC

@keerthi0555 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!  

Translate
Kautuk Sahni
kapil_rajoria
kapil_rajoriaAccepted solution
New Participant
Jun 25, 2024 6:15 AM UTC

Hi @keerthi0555 using the query builder to search for specific components within a page is a common practice. When making query, it is a best practice to use a path that points to the page's content node rather than including the .html extension. It ensures that the query targets the content structure rather than the rendered output.

Translate
arunpatidar
New Participant
Jun 24, 2024 4:04 PM UTC

Hi @keerthi0555 

It depends, if you have that component inside many roots or scattered then yes write a query otherwise you can simply just iterate a tree.

Translate
Arun Patidar