AnsweredAssumed Answered

CONTAINS clause in CMIS Query

Question asked by mlagneaux on Feb 14, 2013
Latest reply on Feb 21, 2013 by jpotts
Hello,

I'm trying to use CONTAINS clause in A CMIS Query to make a fulltext search (I want to get all documents containing a specific word).
I'm working on Alfresco 4.0d.

Here is the code of my CMIS client (I'm using OpenCMIS client 0.6.0) :

List<Document> documentList = new ArrayList<Document>();
      
// build query
ObjectType type = session.getTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value());
PropertyDefinition<?> objectIdPropDef = type.getPropertyDefinitions().get(PropertyIds.OBJECT_ID);
String ObjectIdQueryName = objectIdPropDef.getQueryName();
      
String queryString = MessageFormat.format(QUERY_SEARCH_DOCUMENTS, ObjectIdQueryName, type.getQueryName(), term);
System.out.println("Query : "+queryString);

// execute query
ItemIterable<QueryResult> results = session.query(queryString, false);
for (QueryResult qResult : results) {
   String objectId = qResult.getPropertyValueByQueryName(ObjectIdQueryName);
   System.out.println("objectId : "+objectId);
   Document document = (Document)session.getObject(objectId);
   documentList.add(document);
}


I'm getting the following errors :

Searching documents containing 'test'…
Query : SELECT * FROM cmis:document WHERE CONTAINS('test')
Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Parsing exception!
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.parse(AbstractAtomPubService.java:531)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.DiscoveryServiceImpl.query(DiscoveryServiceImpl.java:147)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl$3.fetchPage(SessionImpl.java:557)
   at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getCurrentPage(AbstractIterator.java:132)
   at org.apache.chemistry.opencmis.client.runtime.util.CollectionIterator.hasNext(CollectionIterator.java:48)
   at fr.virage.service.impl.CMISRemoteServiceImpl.searchDocuments(CMISRemoteServiceImpl.java:110)
   at fr.virage.Main.searchDocuments(Main.java:52)
   at fr.virage.Main.main(Main.java:40)
Caused by: com.ctc.wstx.exc.WstxParsingException: Unrecognized XML directive; expected CDATA or comment ('<![CDATA[' or '<!–').
at [row,col {unknown-source}]: [89,17]
   at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:605)
   at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:461)
   at com.ctc.wstx.sr.BasicStreamReader.nextFromTreeCommentOrCData(BasicStreamReader.java:3285)
   at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2822)
   at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1019)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser.next(AtomPubParser.java:650)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser.skip(AtomPubParser.java:633)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser.parseElement(AtomPubParser.java:380)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser.parseEntry(AtomPubParser.java:295)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser.parseFeed(AtomPubParser.java:256)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser.parse(AtomPubParser.java:120)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.parse(AbstractAtomPubService.java:529)
   … 7 more


I've tried different queries and got different errors.

Which syntax should I use ?
Do I have to use Alfresco CMIS extension to use CONTAINS clause ?

Thx in advance for your help.

Outcomes