How to create query index to get component paths in AEM ? | Community
Skip to main content
Mario248
Level 7
April 24, 2023

How to create query index to get component paths in AEM ?

  • April 24, 2023
  • 3 replies
  • 1055 views

Hello Everyone -I am trying to get all the components that are on the website. I wrote a below query to get the component, 

 

path=/content/my-site/en
1_property=sling:resourceType
p.limit=-1

 

Note I selected "Extract facets" at the top to get all components.

This query works for subpages so there is no problem in the query.

But this query is not working at home page level  as it needs to traverse a lot of nodes. Hence I increased the LimitReads and LimitInMemory property in the JMX console. Also increased Xmx and MaxPermSize values 

 

CQ_JVM_OPTS='-server -Xmx3072m -XX:MaxPermSize=512M -Djava.awt.headless=true'
 

 

 

 

But still AEM is not responsive and it keeps loading and responsive after a few mins. In the logs it recommended to have an index created so I am planning to create an index for my above query but the index generator is not working(below URL). 

 

Oak Index Definition Generator in AEM
http://oakutils.appspot.com/generate/index

 

Could anyone tell me how to write a index for above query ?

 

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

3 replies

Saravanan_Dharmaraj
Community Advisor
Community Advisor
April 24, 2023

@mario248 Could you try the below ?

 

path=/content/my-site/en
property=sling:resourceType
property.operation=exists
p.limit=-1

 

Please check if you have index like this for slingresourceType

 

You can run in explain query tool and see

http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html 

 

I just tested it in my local, i am not getting infinite cost for the same query

 

Mario248
Mario248Author
Level 7
April 25, 2023

Thanks for your response. Even after query index I get below error

 

25.04.2023 22:11:36.611 *WARN* [0:0:0:0:0:0:0:1 [1682440789217] GET /libs/cq/search/content/querydebug.html HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.Cursors$TraversingCursor Traversed 466000 nodes with filter Filter(query=select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] is not null and isdescendantnode(a, '/content/my-website') /* xpath: /jcr:root/content/my-website//*[(@10922553:resourceType)] */, path=/content/my-website//*, property=[sling:resourceType=[is not null]]); consider creating an index or changing the query
 
Log says "consider creating an index" seems it is not considering the query that I placed. 
The instance is stopped response after traversed to 466000 nodes. Do we need to pass the /content/my-site in query index? But as per below index, the system indexed properly and increased the index count.
 

 

 
 
Mario248
Mario248Author
Level 7
April 26, 2023

Yeah, I have the same index but the node name alone is different but node name can be anything I guess

Any other clue?