3.5.4. Search for data and syntax examples

CMIS supports SQL queries for more handful content search. Query service can handle both GET and POST requests. URL for query consists of the repository name and the "/query" method name. The GET request must contain query as a parameter named "q", in case of POST request query must be located in a request body.

For more detailed instructions how to construct queries, refer to the Query examples section.

Using Java

 import org.apache.commons.httpclient.HttpClient;

 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 String url = "http://localhost:8080/rest/private/cmisatom/";
 url += repository;
 url += "/query/";
 HttpClient client = new HttpClient();
 PostMethod post = new PostMethod(url);
 String s = "<?xml version='1.0' encoding='utf-8'?>"
     + "<cmis:query xmlns='http://www.w3.org/2005/Atom' xmlns:cmis='http://docs.oasis-open.org/ns/cmis/core/200908/'>"
     + "<cmis:statement>SELECT * FROM cmis:document</cmis:statement>"
     + "<cmis:maxItems>10</cmis:maxItems>"
     + "<cmis:skipCount>0</cmis:skipCount>"
     + "<cmis:searchAllVersions>true</cmis:searchAllVersions>"
     + "<cmis:includeAllowableActions>true</cmis:includeAllowableActions>"
     + "</cmis:query>";
 RequestEntity entity = new StringRequestEntity(s, "text/xml","utf-8");
 try {
   int result = client.executeMethod(post);
   final String strResponse = post.getResponseBodyAsString();
   // use response...
 } finally {

Using JavaScript

 var url = "http://localhost:8080/rest/private/cmisatom/";

 url += repository;
 url += "/query/";
 var params = {};

 params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
 params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues(someQuery);
 gadgets.io.makeRequest(url, handler, params);
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus