cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS CONTAINS() not finding documents as expected

rmcveigh
Champ in-the-making
Champ in-the-making
I'm using 3.4 Enterprise.  Using the Share UI, I can search for the string "test" and find content nodes as expected.  I can use the advanced search scoped to a custom content type and still find instances of that type.  However, executing a CMIS search isn't finding the documents.  I've tried

select * from cmis:document where CONTAINS('test')

and

select * from my:type where CONTAINS('test')

and a bunch of other permutations and I can't figure out yet what the UI is doing differently to return the documents I expect where I haven't been able to mimic that behavior using a CMIS call.  What is different between the UI? 

I've also tried CONTAINS('TEXT:test') (not sure if that syntax is right) and no luck there either.  I get this exception when I try:

Caused by: org.alfresco.cmis.CMISQueryException: 02140674 Unknown column/property TEXT

I probably misread, but the docs for CMIS query lead me to believe this was possible.  I was reading here: http://wiki.alfresco.com/wiki/CMIS_Query_Language#Differences_between_cmis-strict_and_cmis-alfresco and following the link to the Alfresco FTS docs.

-Ryan
10 REPLIES 10

rmcveigh
Champ in-the-making
Champ in-the-making
I should clarify my goal:  I wish to search for a given string across all indexed properties of a custom content type.  So while this works:  select * from my:type where contains('cmis:name:test')

This isn't realistic unless I want to OR all my custom properties in - which I assumed wasn't necessary.

-Ryan

andy
Champ on-the-rise
Champ on-the-rise
Hi

CONTAINS() uses TEXT as the default field (it may well not be exposed to use direct).
TEXT is any property of type d:content.

The share UI expands the query using something like the macro below:

"%(cm:name cm:title cm:description ia:whatEvent ia:descriptionEvent lnk:title lnk:description TEXT)


ALL can be used from share to search over all properties.
I would have to check if this is exposed in CMIS.


CONTAINS('ALL:test')

It is possible that ALL like TEXT is not exposed in your Alfrecso version…..
so what version are you using and can you post the rest of the stack trace.

Andy

rmcveigh
Champ in-the-making
Champ in-the-making
Hi Andy, thanks for the reply.  I'm running 3.4 Enterprise.  I tried this query: 

SELECT * FROM cmis:document WHERE CONTAINS('ALL:test')

When I do, I get a failure and this is in the log:

Caused by: org.alfresco.cmis.CMISQueryException: 02160067 Unknown column/property ALL
        at org.alfresco.cmis.search.CmisFunctionEvaluationContext.checkFieldApplies(CmisFunctionEvaluationContext.java:366)
        at org.alfresco.repo.search.impl.parsers.FTSQueryParser.buildFieldReference(FTSQueryParser.java:981)
        at org.alfresco.repo.search.impl.parsers.FTSQueryParser.buildFTSTest(FTSQueryParser.java:248)
        at org.alfresco.repo.search.impl.parsers.FTSQueryParser.buildFTSConnective(FTSQueryParser.java:169)
        at org.alfresco.repo.search.impl.parsers.FTSQueryParser.buildFTSConnective(FTSQueryParser.java:156)
        at org.alfresco.repo.search.impl.parsers.FTSQueryParser.buildFTS(FTSQueryParser.java:110)
        at org.alfresco.cmis.search.CMISQueryParser.buildPredicate(CMISQueryParser.java:457)
        at org.alfresco.cmis.search.CMISQueryParser.buildTest(CMISQueryParser.java:283)
        at org.alfresco.cmis.search.CMISQueryParser.buildNegation(CMISQueryParser.java:263)
        at org.alfresco.cmis.search.CMISQueryParser.buildConjunction(CMISQueryParser.java:232)
        at org.alfresco.cmis.search.CMISQueryParser.buildDisjunction(CMISQueryParser.java:205)
        at org.alfresco.cmis.search.CMISQueryParser.parse(CMISQueryParser.java:160)
        at org.alfresco.cmis.search.CMISQueryServiceImpl.query(CMISQueryServiceImpl.java:126)
        at org.alfresco.repo.cmis.rest.CMISScript.query(CMISScript.java:652)

rmcveigh
Champ in-the-making
Champ in-the-making
Andy,

I've experimented some more and I'm able to do some interesting things to perhaps meet my requirement, but I'd like to believe there's a better way.  My requirement is to execute a "full text" search across all indexed fields for a given content type (e.g. cmis:name, myType:field1, myType:field2, cm:content, cm:title, etc).

I can execute a query like: 

select d.*, o.* from cmis:document as d join cm:titled as o on d.cmis:objectid = o.cmis:objectid where CONTAINS(d,'cmis:name:test OR cmis:createdBy:admin') OR CONTAINS(o,'cm:title:test')

This implies I can query on all indexed fields of my type by explicitly OR'ing them in the various scoped CONTAINS predicates.  This seems heavy handed.  Is there a better way?

Another approach which also works is:
select d.*, o.* from cmis:document as d join cm:titled as o on d.cmis:objectid = o.cmis:objectid where o.cm:title like '%25test%25' OR CONTAINS(d,'cmis:name:test')

When would I prefer to use the LIKE predicate over CONTAINS or vice versa?

-Ryan

andy
Champ on-the-rise
Champ on-the-rise
Hi

Sticking to the spec you are allowed one CONTAINS().

For now I would drop the alias in the CONTAINS and "OR" all the terms together in one single contains statement (with no alias)

It I remember correctly, the extended Alfrecso FTS embedded in CMIS should understand embedded "d.cm:content:woof" style. However, as we do not do any actual join and the CMIS contains does not actually check the property binding tot he type (as the default for CONTAINS() is non strict mode).

I will fix up the special pseudo fields like ALL, d:content to work in CMIS contains.

Andy

rmcveigh
Champ in-the-making
Champ in-the-making
Thanks Andy,

I had been unable to use a single CONTAINS statement with both cmis properties and cm:title etc, I had to OR as I described above.  Is there a JIRA issue I can track for the updates you've described?

-Ryan

andy
Champ on-the-rise
Champ on-the-rise

thestorm
Champ in-the-making
Champ in-the-making
whats the variable for fulltext content then? (I wanna query for fulltext index)

andy
Champ on-the-rise
Champ on-the-rise
Hi

The additional fields are exposed in 3.4.3 and the related bug has been resolved.

Until you have this fix: CMIS contains searches all properties of type d:content (if you specify no field) or the specified properties you give.

CONTAINS('woof OR cmis:name:woof')

should search all content and the name property. TEXT:woof will be the same as woof on its own when the additional fields are available.

Andy