Query BUilder | Community
Skip to main content
Keerthi0555
June 24, 2024
Solved

Query BUilder

  • June 24, 2024
  • 4 replies
  • 774 views

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.

Best answer by kapil_rajoria

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

arunpatidar
Community Advisor
Community Advisor
June 24, 2024

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.

Arun Patidar
kapil_rajoria
Community Advisor
kapil_rajoriaCommunity AdvisorAccepted solution
Community Advisor
June 25, 2024

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.

kautuk_sahni
Community Manager
Community Manager
June 25, 2024

@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!  

Kautuk Sahni
Syed_Shaik
September 30, 2025

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
}