Component Instances Report: Need component and count of those across content tree | Community
Skip to main content
Level 2
August 11, 2020
Solved

Component Instances Report: Need component and count of those across content tree

  • August 11, 2020
  • 2 replies
  • 2006 views

I need a report which would list

 

Component 1: 45

Component 2: 78

Component 3: 87

 

Where these are <component>:<instances>

 

There is a acs commons component instances report, but that is per component. What query/report should I use to get this kind of data as output?

 

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 vanegi

You can write a custom logic using JCR API to get the count of the component.

If you want to find the components, then get the list of component names from apps and write a search query for each of the component name. Just a simple JCR Query that would find items containing property jcr:primaryType being cq:Component within /content would work. Depending on what the content structure of your site is, the following XPath query can be used:

 

/jcr:root/content/mysite//*[jcr:primaryType='cq:Component'])
would get you the number of all components in the mysite content tree.

 

https://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

https://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html

 

 

 

2 replies

SundeepKatepally
Community Advisor
Community Advisor
August 11, 2020

Query builder or xpath or sql2 is not as flexible as RDBMS  SQL . As far as i know with a single query we cannot get what your are expecting . Only way is get at the component level using a simple query-builder or sql2 query.

 

vanegi
Adobe Employee
vanegiAdobe EmployeeAccepted solution
Adobe Employee
August 11, 2020

You can write a custom logic using JCR API to get the count of the component.

If you want to find the components, then get the list of component names from apps and write a search query for each of the component name. Just a simple JCR Query that would find items containing property jcr:primaryType being cq:Component within /content would work. Depending on what the content structure of your site is, the following XPath query can be used:

 

/jcr:root/content/mysite//*[jcr:primaryType='cq:Component'])
would get you the number of all components in the mysite content tree.

 

https://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

https://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html