As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
>>> query = "select cmis:objectId, cmis:name from cmis:document where cmis:name like 'test-plain%' order by cmis:lastModificationDate desc" >>> rs = repo.query(query, maxItems="1") >>> rs[0].name u'test-plain-3.txt'
>>> folder = repo.getObjectByPath('/Sites/test-site-1/documentLibrary') >>> query = "select cmis:objectId, cmis:name from cmis:document where in_folder('%s') order by cmis:lastModificationDate desc" % folder.id >>> query "select cmis:objectId, cmis:name from cmis:document where in_folder('workspace://SpacesStore/388e0fed-9104-4507-a702-30c4768e119b') order by cmis:lastModificationDate desc" >>> rs = repo.query(query, maxItems="1") >>> rs[0].name u'test-plain-3.txt'
Probably the easiest thing to do is to order by cmis:lastModificationDate descending. And you can make it more efficient by setting maxItems to 1.>>> query = "select cmis:objectId, cmis:name from cmis:document where cmis:name like 'test-plain%' order by cmis:lastModificationDate desc" >>> rs = repo.query(query, maxItems="1") >>> rs[0].name u'test-plain-3.txt'
Yes, it sucks that I have to retrieve the folder first to get its ID just to build the in_folder clause.
String query = "select * from cmis:document"; OperationContext oc = new OperationContextImpl(); oc.setMaxItemsPerPage(5); ItemIterable<QueryResult> q = getSession().query(query, false, oc);