Expand my Community achievements bar.

Help in improvising query! CRITICAL PROD ISSUE

Avatar

Level 5

Currently we've the following requirement

Search for documents under a certain path with entered search keyword to be either in document title, key, description (three properties for documents). It's taking around 16 seconds for this to run. The effective query is below. Any suggestions what we can do to improve this?

/jcr:root/content/dam/imf/board-meetings/documents//element(*, dam:Asset)[(jcr:contains(jcr:content/metadata/@documentTitle, 'China*') or jcr:contains(jcr:content/metadata/@documentDescription, 'China*') or jcr:contains(jcr:content/metadata/@docKey, 'China*')) and jcr:like(fn:name(), '%.pdf')] order by jcr:content/metadata/@documentDate descending, @jcr:score descending

We are using query builder. However, even if we run this directly in CRX, it takes 16 seconds.

Here is our java code

map.put("type", "dam:Asset");
                        map.put("path", "/content/dam/imf");
                        map.put("nodename", "*.pdf");
                        map.put("1_property", "@jcr:content/metadata/@documentTitle^4.0");
                        map.put("2_property", "@jcr:content/metadata/@documentDescription^3.2");
                        map.put("3_property", "@jcr:content/metadata/@docKey^3.0");
                        map.put("group.p.or", "true");
                        map.put("group.1_fulltext", text + "*");
                           map.put("group.1_fulltext.relPath", "jcr:content/metadata/@documentTitle");
                           
                           map.put("group.2_fulltext", text + "*");
                           map.put("group.2_fulltext.relPath", "jcr:content/metadata/@documentDescription");
                           
                           map.put("group.3_fulltext", text + "*");
                           map.put("group.3_fulltext.relPath", "jcr:content/metadata/@docKey");

    map.put("p.limit", "-1"); 
                        //map.put("orderby", "@jcr:score");
                        //map.put("orderby.sort", "desc");
                        map.put("4_orderby", "@jcr:content/metadata/@documentDate");
                        map.put("4_orderby.sort", "desc");
                        map.put("5_orderby", "@jcr:score");
                        map.put("5_orderby.sort", "desc");

3 Replies

Avatar

Employee Advisor

Do you see any warning messages like "you should consider creating an index" in the log file when you execute this query ?  Try using the explain query tool to analyze what is causing the slow performance - http://adobe-consulting-services.github.io/acs-aem-tools/explain-query.html

Avatar

Level 5

No warnings (this is in 5.6.1)

Are there any documentations to create manual indexes for 5.6.1. I know we use oak:index for 6.1, how about 5.6.1?

Avatar

Level 10

OAK does not apply to 5.6. HEre is an older thread that discusses QB performance. 

https://forums.adobe.com/thread/977920

It talks about OrderBy  and QueryBuilder.