querybuilder basic question

Avatar

Avatar

TB3dock

Avatar

TB3dock

TB3dock

22-03-2021

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?

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

bilala23933647

Avatar

bilala23933647

bilala23933647

22-03-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:

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.

Answers (4)

Answers (4)

Avatar

Avatar

Vijayalakshmi_S

MVP

Avatar

Vijayalakshmi_S

MVP

Vijayalakshmi_S
MVP

22-03-2021

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 @Arun_Patidar @Suraj_Kamdi 

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

879

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

879
Arun_Patidar
MVP

22-03-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 

Avatar

Avatar

Suraj_Kamdi

MVP

Avatar

Suraj_Kamdi

MVP

Suraj_Kamdi
MVP

22-03-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.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