AEM Query Builder search | Community
Skip to main content
September 21, 2024
Solved

AEM Query Builder search

  • September 21, 2024
  • 3 replies
  • 1455 views

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.

 

 

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 h_kataria


 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. 

3 replies

h_kataria
Community Advisor
Community Advisor
September 21, 2024

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-and-indexing-best-practices#explain-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.

AkshayWa2Author
September 22, 2024

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

h_kataria
Community Advisor
Community Advisor
September 23, 2024

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.

daniel-strmecki
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
September 21, 2024

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

AkshayWa2Author
September 22, 2024

@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

kautuk_sahni
Community Manager
Community Manager
September 25, 2024

@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