Search document 📜 by node ☋

cancel
Showing results for 
Search instead for 
Did you mean: 
yone
Member II

Search document 📜 by node ☋

Jump to solution

Hello,

 

We need to create a query to find documents by node.

We have documents with the following properties:

 

<queryResponse>
	<objects>
		<objects>
			<properties>
				<propertyBoolean propertyDefinitionId="cmis:isMajorVersion" localName="isMajorVersion" queryName="cmis:isMajorVersion">
					<s02:value>false
					</s02:value>
				</propertyBoolean>
				<propertyBoolean propertyDefinitionId="scs:doc_valido" localName="doc_valido" displayName="Válido" queryName="scs:doc_valido">
					<s02:value>true
					</s02:value>
				</propertyBoolean>
				<propertyBoolean propertyDefinitionId="cmis:isPrivateWorkingCopy" localName="isPrivateWorkingCopy" queryName="cmis:isPrivateWorkingCopy"/>
				<propertyBoolean propertyDefinitionId="cmis:isLatestMajorVersion" localName="isLatestMajorVersion" queryName="cmis:isLatestMajorVersion">
					<s02:value>false
					</s02:value>
				</propertyBoolean>
				<propertyBoolean propertyDefinitionId="cmis:isImmutable" localName="isImmutable" queryName="cmis:isImmutable">
					<s02:value>false
					</s02:value>
				</propertyBoolean>
				<propertyBoolean propertyDefinitionId="cmis:isLatestVersion" localName="isLatestVersion" queryName="cmis:isLatestVersion">
					<s02:value>true
					</s02:value>
				</propertyBoolean>
				<propertyBoolean propertyDefinitionId="cmis:isVersionSeriesCheckedOut" localName="isVersionSeriesCheckedOut" queryName="cmis:isVersionSeriesCheckedOut">
					<s02:value>false
					</s02:value>
				</propertyBoolean>
				<propertyBoolean propertyDefinitionId="inside:doc_origen" localName="doc_origen" displayName="Origen" queryName="inside:doc_origen">
					<s02:value>true
					</s02:value>
				</propertyBoolean>
				<propertyBoolean propertyDefinitionId="scs:es_revocado" localName="es_revocado" displayName="Consentimiento Revocado" queryName="scs:es_revocado"/>
				<propertyId propertyDefinitionId="alfcmis:nodeRef" localName="nodeRef" queryName="alfcmis:nodeRef">
					<s02:value>workspace://SpacesStore/d6988090-0475-44e0-b346-75041da3cd7b
					</s02:value>
				</propertyId>
				<propertyId propertyDefinitionId="cmis:objectTypeId" localName="objectTypeId" queryName="cmis:objectTypeId">
					<s02:value>D:inside:documento
					</s02:value>
				</propertyId>
				<propertyId propertyDefinitionId="cmis:baseTypeId" localName="baseTypeId" queryName="cmis:baseTypeId">
					<s02:value>cmis:document
					</s02:value>
				</propertyId>
				<propertyId propertyDefinitionId="cmis:versionSeriesCheckedOutId" localName="versionSeriesCheckedOutId" queryName="cmis:versionSeriesCheckedOutId"/>
				<propertyId propertyDefinitionId="cmis:objectId" localName="objectId" queryName="cmis:objectId">
					<s02:value>workspace://SpacesStore/d6988090-0475-44e0-b346-75041da3cd7b;1.1
					</s02:value>
				</propertyId>
				<propertyId propertyDefinitionId="cmis:contentStreamId" localName="contentStreamId" queryName="cmis:contentStreamId">
					<s02:value>store://2019/11/28/15/50/53811130-6cb7-419b-afce-060249a17d0a.bin
					</s02:value>
				</propertyId>
				<propertyId propertyDefinitionId="cmis:versionSeriesId" localName="versionSeriesId" queryName="cmis:versionSeriesId">
					<s02:value>workspace://SpacesStore/d6988090-0475-44e0-b346-75041da3cd7b
					</s02:value>
				</propertyId>
				<propertyInteger propertyDefinitionId="cmis:contentStreamLength" localName="contentStreamLength" queryName="cmis:contentStreamLength">
					<s02:value>15533
					</s02:value>
				</propertyInteger>
				<propertyDateTime propertyDefinitionId="cmis:creationDate" localName="creationDate" queryName="cmis:creationDate">
					<s02:value>2017-03-30T13:22:30.251Z
					</s02:value>
				</propertyDateTime>
				<propertyDateTime propertyDefinitionId="inside:doc_fechaCaptura" localName="doc_fechaCaptura" displayName="Fecha de Captura" queryName="inside:doc_fechaCaptura">
					<s02:value>2017-03-30T13:22:26.565Z
					</s02:value>
				</propertyDateTime>
				<propertyDateTime propertyDefinitionId="cmis:lastModificationDate" localName="lastModificationDate" queryName="cmis:lastModificationDate">
					<s02:value>2017-03-30T13:22:31.206Z
					</s02:value>
				</propertyDateTime>
				<propertyString propertyDefinitionId="scs:doc_sexo" localName="doc_sexo" displayName="Sexo Paciente" queryName="scs:doc_sexo"/>
				<propertyString propertyDefinitionId="cmis:description" localName="description" queryName="cmis:description"/>
				<propertyString propertyDefinitionId="cmis:createdBy" localName="createdBy" queryName="cmis:createdBy">
					<s02:value>
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="inside:doc_valorCSV" localName="doc_valorCSV" displayName="Valor CSV" queryName="inside:doc_valorCSV">
					<s02:value>0gN3S+P8f3GeUqDVLbp7Ch6LuxDXRenGl
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="scs:doc_apellido1" localName="doc_apellido1" displayName="Primer Apellido Paciente" queryName="scs:doc_apellido1"/>
				<propertyString propertyDefinitionId="scs:doc_apellido2" localName="doc_apellido2" displayName="Segundo Apellido Paciente" queryName="scs:doc_apellido2"/>
				<propertyString propertyDefinitionId="cmis:contentStreamFileName" localName="contentStreamFileName" queryName="cmis:contentStreamFileName">
					<s02:value>ES_E00010207_2017_C1A890A28C4D38A2DEBB9B40FE9322.pdf
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="scs:doc_nass" localName="doc_nass" displayName="NASS" queryName="scs:doc_nass">
					<s02:value>051999999971
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="inside:doc_organo" localName="doc_organo" displayName="Organos" queryName="inside:doc_organo">
					<s02:value>E00010207
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="scs:doc_dni" localName="doc_dni" displayName="DNI Paciente" queryName="scs:doc_dni"/>
				<propertyString propertyDefinitionId="scs:id_doc_revocado" localName="id_doc_revocado" displayName="Identificado del Documento de Revocación" queryName="scs:id_doc_revocado"/>
				<propertyString propertyDefinitionId="scs:doc_tamano" localName="doc_tamano" displayName="Tamano de la Digitalizacion" queryName="scs:doc_tamano"/>
				<propertyString propertyDefinitionId="scs:doc_nombre" localName="doc_nombre" displayName="Nombre Paciente" queryName="scs:doc_nombre"/>
				<propertyString propertyDefinitionId="cmis:contentStreamMimeType" localName="contentStreamMimeType" queryName="cmis:contentStreamMimeType">
					<s02:value>application/pdf
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="inside:doc_identificadorDocOrigen" localName="doc_identificadorDocOrigen" displayName="Identificador Documento Origen" queryName="inside:doc_identificadorDocOrigen"/>
				<propertyString propertyDefinitionId="scs:doc_fechaNacimiento" localName="doc_fechaNacimiento" displayName="Fecha de Nacimiento Paciente" queryName="scs:doc_fechaNacimiento"/>
				<propertyString propertyDefinitionId="inside:doc_identificador" localName="doc_identificador" displayName="Identificador" queryName="inside:doc_identificador">
					<s02:value>ES_E00010207_2017_C1A890A28C4D38A2DEBB9B40FE9322
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="inside:doc_versionNTI" localName="doc_versionNTI" displayName="Version NTI" queryName="inside:doc_versionNTI">
					<s02:value>
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="inside:doc_tipoFirma" localName="doc_tipoFirma" displayName="Tipo de Firma" queryName="inside:doc_tipoFirma"/>
				<propertyString propertyDefinitionId="scs:doc_sns" localName="doc_sns" displayName="SNS" queryName="scs:doc_sns"/>
				<propertyString propertyDefinitionId="scs:doc_firma" localName="doc_firma" displayName="Valor Firma" queryName="scs:doc_firma">
					<s02:value>
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="scs:doc_numHistoriaClinica" localName="doc_numHistoriaClinica" displayName="Numero de Historia Clinica" queryName="scs:doc_numHistoriaClinica">
					<s02:value>11645069
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="cmis:versionLabel" localName="versionLabel" queryName="cmis:versionLabel">
					<s02:value>1.1
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="cmis:checkinComment" localName="checkinComment" queryName="cmis:checkinComment"/>
				<propertyString propertyDefinitionId="inside:doc_estadoElaboracion" localName="doc_estadoElaboracion" displayName="Estado de Elaboración" queryName="inside:doc_estadoElaboracion">
					<s02:value>EE99
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="cmis:name" localName="name" queryName="cmis:name">
					<s02:value>ES_E00010207_2017_C1A890A28C4D38A2DEBB9B40FE9322.pdf
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="scs:doc_numExpediente" localName="doc_numExpediente" displayName="Numero de Expediente" queryName="scs:doc_numExpediente">
					<s02:value>11645069
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="inside:doc_tipoDocumental" localName="doc_tipoDocumental" displayName="Tipo Documental" queryName="inside:doc_tipoDocumental">
					<s02:value>TD02
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="scs:doc_idioma" localName="doc_idioma" displayName="Idioma de la Digitalizacion" queryName="scs:doc_idioma"/>
				<propertyString propertyDefinitionId="cmis:lastModifiedBy" localName="lastModifiedBy" queryName="cmis:lastModifiedBy">
					<s02:value>
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="scs:doc_resolucion" localName="doc_resolucion" displayName="Resolucion de la Digitalizacion" queryName="scs:doc_resolucion"/>
				<propertyString propertyDefinitionId="inside:doc_defGeneracionCSV" localName="doc_defGeneracionCSV" displayName="Definición Generación CSV" queryName="inside:doc_defGeneracionCSV"/>
				<propertyString propertyDefinitionId="cmis:changeToken" localName="changeToken" queryName="cmis:changeToken"/>
				<propertyString propertyDefinitionId="inside:doc_nombreFormato" localName="doc_nombreFormato" displayName="Nombre de Formato" queryName="inside:doc_nombreFormato">
					<s02:value>PDF
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="cmis:versionSeriesCheckedOutBy" localName="versionSeriesCheckedOutBy" queryName="cmis:versionSeriesCheckedOutBy"/>
				<propertyString propertyDefinitionId="scs:doc_certificado" localName="doc_certificado" displayName="Valor Certificado" queryName="scs:doc_certificado">
					<s02:value>
					</s02:value>
				</propertyString>
				<propertyString propertyDefinitionId="scs:valorCSV_revocado" localName="valorCSV_revocado" displayName="Valor CSV del Documento de Revocación" queryName="scs:valorCSV_revocado"/>
			</properties>
		</objects>
	</objects>
</queryResponse>

 

 

We have tried to find it using the nodeRef query, as follows:

 

SELECT * FROM inside:documento WHERE alfcmis:nodeRef=1234

And the systems responds to us:

 

Column refers to unqueryable property alfcmis:nodeRef

 

In addition we have also tried to use a real nodeRef value:

 

SELECT * FROM inside:documento WHERE alfcmis:nodeRef=workspace://SpacesStore/d6988090-0475-44e0-b346-75041da3cd7b

However the system replies to us:

 

line 1:53 mismatched input 'workspace:' expecting COLON ([@12,53:62='workspace:',<37>,1:53]) in where
[query, whereClause, searchOrCondition, searchAndCondition, searchNotCondition, searchTest, predicate, comparisonPredicate, literalOrParameterName, parameterName, recoverFromMismatchedToken]

 

To solve the previous issue we have found that we maybe should use colon instead of equal sign:

https://docs.alfresco.com/4.2/concepts/rm-searchsyntax-fields.html

 

So then, we wrote:

 

SELECT * FROM inside:documento WHERE alfcmis:nodeRef:workspace://SpacesStore/d6988090-0475-44e0-b346-75041da3cd7b

And the output is:

 

line 1:63 no viable alternative at character '/'

 

Due to the last exception we found that strings would need to be enclosed in single quotes '' and special characters be escaped with backslashes \

https://stackoverflow.com/questions/34940423/error-in-calling-cmis-query-if-string-contains-single-o...

Then we tried both approaches, first with single quotes:

 

SELECT * FROM inside:documento WHERE alfcmis:nodeRef:'workspace://SpacesStore/d6988090-0475-44e0-b346-75041da3cd7b
'

And the output would be:

 

ine 1:53 no viable alternative at input ''workspace://SpacesStore/d6988090-0475-44e0-b346-75041da3cd7b\n''
(decision=28 state 66) decision=<<569:1: predicate : ( comparisonPredicate | inPredicate | likePredicate | nullPredicate | quantifiedComparisonPredicate | quantifiedInPredicate | textSearchPredicate | folderPredicate );>> in where
[query, whereClause, searchOrCondition, searchAndCondition, searchNotCondition, searchTest, predicate]
faultactor=

Besides we tried the second approach, with backslashes:

 

SELECT * FROM inside:documento WHERE alfcmis:nodeRef:'workspace:\/\/SpacesStore\/d6988090-0475-44e0-b346-75041da3cd7b
'

 

 

And the systems replies with:

1:53 no viable alternative at input ''workspace:\/\/SpacesStore\/d6988090-0475-44e0-b346-75041da3cd7b\n''
(decision=28 state 66) decision=<<569:1: predicate : ( comparisonPredicate | inPredicate | likePredicate | nullPredicate | quantifiedComparisonPredicate | quantifiedInPredicate | textSearchPredicate | folderPredicate );>> in where
[query, whereClause, searchOrCondition, searchAndCondition, searchNotCondition, searchTest, predicate]

 

As well we have read:

https://docs.alfresco.com/6.1/concepts/dev-api-by-language-alf-rest-finding-content-by-search-query....

https://docs.alfresco.com/6.1/concepts/dev-api-by-language-alf-rest-finding-content-by-term.html

https://docs.alfresco.com/6.1/concepts/dev-api-by-language-alf-rest-searching-for-nodes.html

https://docs.alfresco.com/4.2/references/API-JS-findNode.html

https://stackoverflow.com/questions/24190975/alfresco-unable-to-cmis-query-by-path

https://docs.alfresco.com/search-enterprise/concepts/searchsyntax-escaping.html

 

 

1 Solution

Accepted Solutions
angelborroy
Alfresco Employee

Re: Search document 📜 by node ☋

Jump to solution

alfcmis:nodeRef is not queriable.

Try something like:

 

SELECT * FROM cmis:document where cmis:objectId = 'f7be870e-a591-4469-9a4e-5120a368a5f4'

As every node in the CMIS Space is belonging to "workspace://SpacesStore" and you don't need to specify that.

 

Hyland Developer Evangelist

View solution in original post

1 Reply
angelborroy
Alfresco Employee

Re: Search document 📜 by node ☋

Jump to solution

alfcmis:nodeRef is not queriable.

Try something like:

 

SELECT * FROM cmis:document where cmis:objectId = 'f7be870e-a591-4469-9a4e-5120a368a5f4'

As every node in the CMIS Space is belonging to "workspace://SpacesStore" and you don't need to specify that.

 

Hyland Developer Evangelist