Expand my Community achievements bar.

SOLVED

querybuilder basic question

Avatar

Level 9

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?

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 7

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:

bilala23933647_0-1616429468791.png

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.

View solution in original post

7 Replies

Avatar

Community Advisor

@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.h... 

 

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

 

Avatar

Community Advisor

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

Avatar

Level 10

Hi @TB3dock,

Use this http://localhost:4502/bin/querybuilder.json?type=cq:Page&orderby=@jcr:content/cq:lastModified&p.limi..., 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 

Avatar

Correct answer by
Level 7

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:

bilala23933647_0-1616429468791.png

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.

Avatar

Level 9
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.

Avatar

Level 7

Hey @TB3dock, first login using this URL: http://localhost:4502/crx/explorer/index.jsp 

and then click on 'Node Type Administration', that will take you to the place you wanted.

 

Thanks!

Bilal.