Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

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

Avatar

Level 9

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.

Mario248_0-1682352765953.png

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'
 

 

 

Mario248_1-1682352866741.png

 

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 ?

 

3 Replies

Avatar

Community Advisor

@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

Saravanan_Dharmaraj_0-1682358094270.png

 

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

 

Avatar

Level 9

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//*[(@sling: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_0-1682442092371.png

 

 
 

Avatar

Level 9

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

Mario248_0-1682512566566.png

Any other clue?