cmisopencmis

Get all documents within a folder or site that has a specific Aspect property value?


I have an aspect that I have associated with multiple documents. For example lests call the aspect OrderAspect.

The below query works when I fetch all nodes that have a location property from OrderAspect set to 'WAREHOUSE-A'

SELECT * FROM oa:OrderAspect WHERE oa:Location ='WAREHOUSE-A'

  1. How can I extend this query to get ONLY documents that have this aspect value as 'WAREHOUSE-A'.

  2. Can I extend this query to search within a folder path or site? I would like to list all the documents within a folder (including subfolder) or a site that has OrderAspect with property location set to 'WAREHOUSE-A'.


Solution

  • Here is how you do a CMIS query that restricts results to a value defined in an aspect:

    select D.cmis:name from cmis:document as D join sc:temp as T on D.cmis:objectId = T.cmis:objectId where T.sc:prop1 = 'value1'
    

    Here is how you add an AND clause to require that the result be in a certain path, including sub-folders:

    select D.cmis:name from cmis:document as D join sc:temp as T on D.cmis:objectId = T.cmis:objectId where T.sc:prop1 = 'value1' AND CONTAINS(D, 'PATH:\"/app:company_home/st:sites/cm:jtp-test-site-1/cm:documentLibrary//*\"')