My task is to display random images every time user hits the browser.So I want to fetch random images from JCR. My code is as follows
Map<String, String> map = new HashMap<String,String>();map.put("path", contentPath.toString());map.put("type", "dam.Asset");map.put("property", "jcr:content/metadata/dc:format"); map.put("property.value", "image/jpeg");
Is it possible to achieve this using Query Builder API?
Please suggest how I can achieve the same.
no, the JCR query language does not have any randomizer, but the result set is a collection and you can always use the Java Collections.shuffle(List<?>).
A better solution, if you are going to collect from a named path, is to use the http://dev.day.com/docs/en/cq/current/javadoc/org/apache/sling/api/resource/ResourceWrapper.html#get....