Expand my Community achievements bar.

SOLVED

How to sort the assets ascending order using query builder?

Avatar

Level 4

Hi,

i tried to sort the assets to alpha numeric format using query builder.

The below Query executing but i dont get the result in ascending order. 

 

/jcr:root/content/dam//element(*, dam:Asset) 
[
(jcr:content/metadata/@dam:MIMEtype = 'image/jpeg' or jcr:content/metadata/@dam:MIMEtype = 'image/png' or jcr:content/metadata/@dam:MIMEtype = 'image/jpg' ) 
]
order by jcr:content/@jcr:title ASC

 

Please help me how to proceed.

Thanks,

Michael

1 Accepted Solution

Avatar

Correct answer by
Level 10

This works:

http://localhost:4502/bin/querybuilder.json?type=nt:file&nodename=*.jar&orderby=@jcr:content/jcr:las...

https://docs.adobe.com/docs/en/cq/5-6-1/dam/customizing_and_extendingcq5dam/query_builder.html

Here is the JSON result - noticed its sorted by title: 

{  
   "success":true,
   "results":10,
   "total":213,
   "more":false,
   "offset":0,
   "hits":[  
      {  
         "path":"/apps/acs-commons/install/acs-aem-commons-bundle-1.10.2.jar",
         "excerpt":"",
         "name":"acs-aem-commons-bundle-1.10.2.jar",
         "title":"acs-aem-commons-bundle-1.10.2.jar",
         "lastModified":"2015-08-05 11:37:02",
         "created":"2015-08-05 11:37:02",
         "size":"617 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/acs-commons/install/acs-aem-commons-bundle-twitter-1.10.2.jar",
         "excerpt":"",
         "name":"acs-aem-commons-bundle-twitter-1.10.2.jar",
         "title":"acs-aem-commons-bundle-twitter-1.10.2.jar",
         "lastModified":"2015-08-05 11:37:02",
         "created":"2015-08-05 11:37:02",
         "size":"23 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/customer/osgi-bundles/install/customerdb-bundle-1.0-SNAPSHOT.jar",
         "excerpt":"",
         "name":"customerdb-bundle-1.0-SNAPSHOT.jar",
         "title":"customerdb-bundle-1.0-SNAPSHOT.jar",
         "lastModified":"2015-07-14 16:04:48",
         "created":"2015-07-14 16:04:48",
         "size":"10 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/customer/osgi-bundles/install/SQLDriverFile_1.0.0.jar",
         "excerpt":"",
         "name":"SQLDriverFile_1.0.0.jar",
         "title":"SQLDriverFile_1.0.0.jar",
         "lastModified":"2015-07-14 16:04:48",
         "created":"2015-07-14 16:04:48",
         "size":"706 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/libs/cq/dialogconversion/install/cq-dialog-conversion-1.0.2.jar",
         "excerpt":"",
         "name":"cq-dialog-conversion-1.0.2.jar",
         "title":"cq-dialog-conversion-1.0.2.jar",
         "lastModified":"2015-07-07 14:54:06",
         "created":"2015-07-07 14:54:06",
         "size":"30 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/slingSevletApp/osgi-bundles/install/claim-bundle-1.0-SNAPSHOT.jar",
         "excerpt":"",
         "name":"claim-bundle-1.0-SNAPSHOT.jar",
         "title":"claim-bundle-1.0-SNAPSHOT.jar",
         "lastModified":"2015-06-22 10:59:27",
         "created":"2015-06-22 10:59:27",
         "size":"7 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/slingSevletApp/osgi-bundles/install/SimpleJSON_1.0.0.jar",
         "excerpt":"",
         "name":"SimpleJSON_1.0.0.jar",
         "title":"SimpleJSON_1.0.0.jar",
         "lastModified":"2015-06-22 10:59:27",
         "created":"2015-06-22 10:59:27",
         "size":"22 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/libs/cq/contentinsight/install/cq-content-insight-1.1.12.jar",
         "excerpt":"",
         "name":"cq-content-insight-1.1.12.jar",
         "title":"cq-content-insight-1.1.12.jar",
         "lastModified":"2015-06-04 16:43:35",
         "created":"2015-06-04 16:43:35",
         "size":"39 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/libs/cq/projects/install/com.adobe.cq.projects.core-0.1.60.jar",
         "excerpt":"",
         "name":"com.adobe.cq.projects.core-0.1.60.jar",
         "title":"com.adobe.cq.projects.core-0.1.60.jar",
         "lastModified":"2015-06-04 16:43:33",
         "created":"2015-06-04 16:43:33",
         "size":"235 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/libs/cq/projects/install/com.adobe.cq.projects.wcm.core-0.1.6.jar",
         "excerpt":"",
         "name":"com.adobe.cq.projects.wcm.core-0.1.6.jar",
         "title":"com.adobe.cq.projects.wcm.core-0.1.6.jar",
         "lastModified":"2015-06-04 16:43:33",
         "created":"2015-06-04 16:43:33",
         "size":"20 KB",
         "mimeType":"application/java-archive"
      }
   ]
}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

This works:

http://localhost:4502/bin/querybuilder.json?type=nt:file&nodename=*.jar&orderby=@jcr:content/jcr:las...

https://docs.adobe.com/docs/en/cq/5-6-1/dam/customizing_and_extendingcq5dam/query_builder.html

Here is the JSON result - noticed its sorted by title: 

{  
   "success":true,
   "results":10,
   "total":213,
   "more":false,
   "offset":0,
   "hits":[  
      {  
         "path":"/apps/acs-commons/install/acs-aem-commons-bundle-1.10.2.jar",
         "excerpt":"",
         "name":"acs-aem-commons-bundle-1.10.2.jar",
         "title":"acs-aem-commons-bundle-1.10.2.jar",
         "lastModified":"2015-08-05 11:37:02",
         "created":"2015-08-05 11:37:02",
         "size":"617 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/acs-commons/install/acs-aem-commons-bundle-twitter-1.10.2.jar",
         "excerpt":"",
         "name":"acs-aem-commons-bundle-twitter-1.10.2.jar",
         "title":"acs-aem-commons-bundle-twitter-1.10.2.jar",
         "lastModified":"2015-08-05 11:37:02",
         "created":"2015-08-05 11:37:02",
         "size":"23 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/customer/osgi-bundles/install/customerdb-bundle-1.0-SNAPSHOT.jar",
         "excerpt":"",
         "name":"customerdb-bundle-1.0-SNAPSHOT.jar",
         "title":"customerdb-bundle-1.0-SNAPSHOT.jar",
         "lastModified":"2015-07-14 16:04:48",
         "created":"2015-07-14 16:04:48",
         "size":"10 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/customer/osgi-bundles/install/SQLDriverFile_1.0.0.jar",
         "excerpt":"",
         "name":"SQLDriverFile_1.0.0.jar",
         "title":"SQLDriverFile_1.0.0.jar",
         "lastModified":"2015-07-14 16:04:48",
         "created":"2015-07-14 16:04:48",
         "size":"706 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/libs/cq/dialogconversion/install/cq-dialog-conversion-1.0.2.jar",
         "excerpt":"",
         "name":"cq-dialog-conversion-1.0.2.jar",
         "title":"cq-dialog-conversion-1.0.2.jar",
         "lastModified":"2015-07-07 14:54:06",
         "created":"2015-07-07 14:54:06",
         "size":"30 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/slingSevletApp/osgi-bundles/install/claim-bundle-1.0-SNAPSHOT.jar",
         "excerpt":"",
         "name":"claim-bundle-1.0-SNAPSHOT.jar",
         "title":"claim-bundle-1.0-SNAPSHOT.jar",
         "lastModified":"2015-06-22 10:59:27",
         "created":"2015-06-22 10:59:27",
         "size":"7 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/apps/slingSevletApp/osgi-bundles/install/SimpleJSON_1.0.0.jar",
         "excerpt":"",
         "name":"SimpleJSON_1.0.0.jar",
         "title":"SimpleJSON_1.0.0.jar",
         "lastModified":"2015-06-22 10:59:27",
         "created":"2015-06-22 10:59:27",
         "size":"22 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/libs/cq/contentinsight/install/cq-content-insight-1.1.12.jar",
         "excerpt":"",
         "name":"cq-content-insight-1.1.12.jar",
         "title":"cq-content-insight-1.1.12.jar",
         "lastModified":"2015-06-04 16:43:35",
         "created":"2015-06-04 16:43:35",
         "size":"39 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/libs/cq/projects/install/com.adobe.cq.projects.core-0.1.60.jar",
         "excerpt":"",
         "name":"com.adobe.cq.projects.core-0.1.60.jar",
         "title":"com.adobe.cq.projects.core-0.1.60.jar",
         "lastModified":"2015-06-04 16:43:33",
         "created":"2015-06-04 16:43:33",
         "size":"235 KB",
         "mimeType":"application/java-archive"
      },
      {  
         "path":"/libs/cq/projects/install/com.adobe.cq.projects.wcm.core-0.1.6.jar",
         "excerpt":"",
         "name":"com.adobe.cq.projects.wcm.core-0.1.6.jar",
         "title":"com.adobe.cq.projects.wcm.core-0.1.6.jar",
         "lastModified":"2015-06-04 16:43:33",
         "created":"2015-06-04 16:43:33",
         "size":"20 KB",
         "mimeType":"application/java-archive"
      }
   ]
}

Avatar

Administrator

Hi michaelvino86

Please follow the following steps to look at the results :-

1.Please go to the link :- http://localhost:4502/libs/cq/search/content/querydebug.html (for query builder tool)

2. check Extract facets

3. type=dam:Asset
     path=/content/dam/geometrixx
    nodename=*.png
    orderby=@jcr:content/jcr:lastModified
    orderby.sort=desc 

 

//Result 

or 

type=dam:Asset
path=/content/dam/geometrixx
nodename=*.png
orderby=@jcr:content/jcr:lastModified
orderby.sort=asc

// Result 

Its working for me, and as mentioned by Scott in above post, its also working for him too.

Please follow the link :- http://cq-ops.tumblr.com/post/23543240500/how-to-use-cqs-query-debugger-tool  or Link:- https://docs.adobe.com/docs/en/cq/5-6-1/dam/customizing_and_extendingcq5dam/query_builder.html 

I hope this would help you.

 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni