querybuilder basic question | Community
Skip to main content
Level 8
March 22, 2021
Solved

querybuilder basic question

  • March 22, 2021
  • 5 replies
  • 2027 views

Here we have some example queries:

 

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/querybuilder-api.html

 

This example: 

 

http://localhost:4502/bin/querybuilder.json?type=cq:Page&orderby=@jcr:content/cq:lastModified

 

returns things like this:

 

  1. hits: [{path: "/etc/security/accountmgr", excerpt: "Service Configuration for Account Self-Service",…},…]
    1. 0: {path: "/etc/security/accountmgr", excerpt: "Service Configuration for Account Self-Service",…}
      1. excerpt: "Service Configuration for Account Self-Service"
      2. lastModified: "2009-03-16 15:46:13"
      3. name: "accountmgr"
      4. path: "/etc/security/accountmgr"
      5. title: "Self-Service Configuration"

 

Questions:

  1. None of the results are actually pages from the site?  The site we have locally is the wknd starter site.  How do you return pages from the site hosted in AEM?
  2. type=cq:Page what other types are available?  Is this the type of the items searched, or the type of the items returned?

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by bilal_ahmad

Hey @tb3dock,

The query(xpath) you shared is : //element(*, cq:Page)
order by jcr:content/@cq:lastModified

 

you are actually searching at the root level, i.e /

 

the results it has returned are 7665 in my case. also It has displayed/presented only 10 results to you(rest are there in hits count). Add this - p.limit=-1 and you'll be able to see al the results on the same page:

now to your questions:
Q1. None of the results are actually pages from the site?  The site we have locally is the wknd starter site.  How do you return pages from the site hosted in AEM?
A1. Because you are searching at root (/) these are all cq:Page results, but in order to get specific results from your site, you need to specify your specific project path(like path=/content/we-retail). This is the way you return the intended pages from your AEM instance.

 

Q2. type=cq:Page what other types are available?  Is this the type of the items searched, or the type of the items returned?

A2. There are other node types as well. such as dam:Asset, nt:unstructured, etc. please visit this URL: http://localhost:4502/crx/explorer/nodetypes/index.jsp and you'll find all the registered node types you can query on.



I hope that helps 🙂

 

Thanks,

Bilal.

5 replies

Suraj_Kamdi
Community Advisor
Community Advisor
March 22, 2021

@tb3dock 

Here is the list of all the primary types available in AEM

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/custom-nodetypes.html?lang=en#platform 

 

If you want to return the specific set of pages with the following sample query 

 

path=/content/game type=cq:page property=cq:primaryType property.value=sample/components/structure/game-overview p.limit=-1

 

Suraj Kamdi
arunpatidar
Community Advisor
Community Advisor
March 22, 2021

Please go through https://hashimkhan.in/aem-adobecq5-code-templates/query-builder/ to learn more about querybuilder and available predicates and possibilities to achieve using the query builder 

Arun Patidar
Vijayalakshmi_S
Level 10
March 22, 2021

Hi @tb3dock,

Use this http://localhost:4502/bin/querybuilder.json?type=cq:Page&orderby=@jcr:content/cq:lastModified&p.limit=-1, you will see the entire result set/resources of type cq:Page

By default, 10 results are returned. If you specifiy "p.limit=-1", it will bring in entire matching/applicable results.

Answer to your queries inline in bold.

Questions:

  • None of the results are actually pages from the site?  The site we have locally is the wknd starter site.  How do you return pages from the site hosted in AEM?
    • If you use above query, you will see your site pages available as part of the result set.
  • type=cq:Page what other types are available?  Is this the type of the items searched, or the type of the items returned?
    • Both + It also influences the index used for query execution.
    • For list of types available and other predicates used as part of query, you can refer the links shared by @bhuwan_b @arunpatidar @suraj_kamdi 
bilal_ahmad
bilal_ahmadAccepted solution
Level 5
March 22, 2021

Hey @tb3dock,

The query(xpath) you shared is : //element(*, cq:Page)
order by jcr:content/@cq:lastModified

 

you are actually searching at the root level, i.e /

 

the results it has returned are 7665 in my case. also It has displayed/presented only 10 results to you(rest are there in hits count). Add this - p.limit=-1 and you'll be able to see al the results on the same page:

now to your questions:
Q1. None of the results are actually pages from the site?  The site we have locally is the wknd starter site.  How do you return pages from the site hosted in AEM?
A1. Because you are searching at root (/) these are all cq:Page results, but in order to get specific results from your site, you need to specify your specific project path(like path=/content/we-retail). This is the way you return the intended pages from your AEM instance.

 

Q2. type=cq:Page what other types are available?  Is this the type of the items searched, or the type of the items returned?

A2. There are other node types as well. such as dam:Asset, nt:unstructured, etc. please visit this URL: http://localhost:4502/crx/explorer/nodetypes/index.jsp and you'll find all the registered node types you can query on.



I hope that helps 🙂

 

Thanks,

Bilal.

TB3dockAuthor
Level 8
March 22, 2021
Very useful, thanks! that index.jsp link you suggest gives Unable to retrieve node type manager probably due to insufficiant rights. Please login as a more priviledged user. javax.jcr.AccessDeniedException: Root node is not accessible. Currently Im logged in as admin.