Chekout this : http://cq5demosearch.wordpress.com/2013/10/20/building-search-in-cq/You can use the below code :String xPathQuery = “/jcr:root/content/mydemosite/documents/Sales//element(*,nt:file)[jcr:like(@name,'%"+docName+"%')]“; //docName is search queryxPathQuery += ” order by @jcr:score ascendi...