08-29-2018 08:34 AM
I am trying to execute the following CMIS query that searches for all documents within a site that have the docStatus property set to 'Active' from defaultAspect type. The query errors out stating the below issue. Please can you let me know what is wrong with the query.
Error Content:
{"exception":"invalidArgument","message":"No selector for "}
Query
SELECT d.* FROM cmis:document AS d JOIN td:defaultAspect as p ON d.cmisbjectId = p.cmisbjectId WHERE td:docStatus ='Active' and CONTAINS('PATH:\"/app:company_home/st:sites/cm:testsite/cm:documentLibrary//*\"')
08-29-2018 12:20 PM
Try the following sentence:
SELECT * FROM td:defaultAspect WHERE td:docStatus ='Active' and CONTAINS('PATH:\"/app:company_home/st:sites/cm:testsite/cm:documentLibrary//*\"')
08-29-2018 03:30 PM
I believe you cannot select only on an aspect. You have to use a CMIS base type, even if that is just cmis:item, and then join with the aspect..
08-30-2018 02:49 AM
Axel, this query is working:
SELECT * FROM cm:titled
I've been writing queries by using only aspects many times. Am I wrong or I missed something?
08-30-2018 05:07 AM
As discussed in the IRC channel, the spec explicitlely states that only primary object types are supported in the FROM clause, but Alfresco has implemented it in a way that aspects / secondary object types can also be used. The reason for this is that the text of the spec was not fully consistent with the BNF of the query language, and Alfresco apparently followed the text more closely than the formal definition.
08-29-2018 06:50 PM
Here is how you do a join so that you can query aspect-based properties while simultaneously restricted the results to those in a certain path:
select D.cmis:name from cmis:document as D join sc:temp as T on D.cmisbjectId = T.cmisbjectId where T.scrop1 = 'value1' AND CONTAINS(D, 'PATH:\"/app:company_home/st:sites/cm:jtp-test-site-1/cm:documentLibrary//*\"')
The missing tidbit is that because you are doing a join, the selector ("D") has to be specified in the CONTAINS.
08-30-2018 11:36 AM
I believe you got ample answers. I do like below, in case it helps in any way
SELECT doc.*, slo.* FROM cmis:document AS doc JOIN slo:documentProperties AS slo ON doc.cmisbjectId = slo.cmisbjectId WHERE IN_FOLDER(doc, 'workspace://SpacesStore/3105f215-228e-4087-aef8-4a9399eb0b60') AND (slo.slo:m_link = 128) AND (slo.slo:m_category = 'Person')
m_link and m_category are the aspect properties
I have an aspect defined this way in our own custom model. Here is an extract of our custom model.
<types>
<!-- custom document type -->
<type name="slo:mdocument">
<title>SLO Document type</title>
<parent>cm:content</parent>
<!-- associations section - no associations as of now -->
<!-- aspect is defined to hold all the properties -->
<mandatory-aspects>
<aspect>slo:documentProperties</aspect>
</mandatory-aspects>
</type>
</types>
<aspects>
<!-- There is one aspect with all the custom properties defined -->
<aspect name="slo:documentProperties">
<title>m document properties</title>
<properties>
<property name="slo:m_category">
<title>Category</title>
<type>d:text</type>
</property>
<property name="slo:m_link">
<title>Link ID</title>
<type>d:int</type>
</property>
....
Explore our Alfresco products with the links below. Use labels to filter content by product module.