Expand my Community achievements bar.

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

AEM Query Builder search

Avatar

Level 2

Hi All,

 

We have below full text query which is used to find pages under certain hierarchy and also with specific type of resourceType.

 

Sample query 1:

fulltext=random text

group.1_path=/content/us/en

group.2_path=/content/ca/en

group.p.or=true

property = jcr:content/sling:resourceType

property.1_value = project-one/components/structure/article-detail

property.2_value = project-two/components/structure/article-detail

 

We are getting results for above query in 300-400 milliseconds.

 

Now we have to bring ALL the pages under certain hierarchy and also with specific type of resourceType. (somewhat initially loading of articles on homepage) we are using same query but not using "fulltext" property.

 

Sample query 2:

group.1_path=/content/us/en

group.2_path=/content/ca/en

group.p.or=true

property = jcr:content/sling:resourceType

property.1_value = project-one/components/structure/article-detail

property.2_value = project-two/components/structure/article-detail

 

Here we are getting results in 3000-4000 milliseconds approximately 10 times to  above Sample query 1.

 

Not sure why how much time difference. Can someone guide on same.

 

 

8 Replies

Avatar

Community Advisor

Your first query is probably picking pathreference index due to which execution time is less.

You can use explain query tool to understand which indexes are being used for which queries
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/operations/query... 

You can try adding type=cq:Page to your second query, since you are probably trying to just identify the pages with given resourceType, it might help in reducing the execution time since then the query will pick cqPageLuceneIndex.

type=cq:Page

group.1_path=/content/us/en

group.2_path=/content/ca/en

group.p.or=true

property = jcr:content/sling:resourceType

property.1_value = project-one/components/structure/article-detail

property.2_value = project-two/components/structure/article-detail

Hope this helps.

Avatar

Level 2

Above queries are already picking cqPageLuceneIndex also after adding type=cq:Page no major time difference is seen.

Avatar

Community Advisor

Is it possible to share screenshots from explain query tool for both your queries ? 
If same index is being picked for both your queries, it is interesting to see how the second query is taking more time.

Avatar

Community Advisor

 I checked on both AEM6.5 as well as on AEMaaCS SDK and execution plan looks different. 
And for both versions cqPageLucene is not being picked unless I specifically add the type predicate. 
So, there might be some customizations done in your project to the indexes which you can possibly check. 

Avatar

Level 4

I agree with @h_kataria, but just wanted to add one more thought. We have some quite complex queries on our project and cannot optimize them further. Therefore, for the ones that take a long time, we use an in-memory cache. A cache can be based on TTL if that is acceptable, or you can invalidate it with a content modification listener.

 

Good luck,

Daniel

Avatar

Level 2

@daniel-strmecki yeah caching probably would be the last option for me. I am just curious to know why fulltext= "random text" and fulltext = " " take so much time difference. Both are using cqPageLuceneIndex in my case. Not sure I should add some extra parameters for empty string search

Avatar

Administrator

@AkshayWa2 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni