How to query index of Document (the "ecm:pos") via Java API?

While coreSession.query() works fine for “SELECT * FROM Document WHERE … order by ecm:pos " i do not find a way to get this ecm:pos value.

Unfortunately, it is not one of the getters of DocumentModel. The simple trial with “SELECT * , ecm:pos FROM” does not throw an error, but always 0 items (at least against SQLRepositoryTestCase)

  • and if it would work, what is the result object's type?, The only docs i found are the NXQL spec and the API (but i'am sure, i missed some)

Thanks,

[And as this is my first post ever: Many thanks for nuxeo! Great job!]

0 votes

1 answers

2576 views

ANSWER



Today the only way to get at the ecm:pos of a document is to do a query using the queryAndFetch API and request the value of ecm:pos:

SELECT ecm:uuid, ecm:pos, ... FROM Document WHERE ...
1 votes



Thanks, works fine. And by that way I found that the ecm:pos is missing in the proxy of my document, at least gives me null for ecm:pos, although the facet set still contains Orderable. I will investigte this further…

Just for the record (Nuxeo 5.5, SQLRepositoryTestCase):

String queryS = "SELECT " + BuiltinDocumentFields.FIELD_DOC_UUID + " , " + " ecm:pos " + " FROM Document WHERE " + BuiltinDocumentFields.FIELD_DOC_PARENT_REF + " = '" + modelResultAttfolder1.getId() + "' " + " and " + BuiltinDocumentFields.FIELD_DOC_TYPE + " = '" + BgiAttachmentsitemDef.ECM_DOC_NAME_MAIN + "' " + " and " + BuiltinDocumentFields.FIELD_DOC_IS_PROXY + " = " + "0 " + " order by ecm:pos ";

retDMLIterqr = coreSession.queryAndFetch( queryS, "NXQL" );

log.debug( "testSearchAndOrder1: iQueryRound=" + iQueryRound + " iItem=" + iItem + " : map=" + map );

14:00:32,060 DEBUG [FirstDscNXMyTest] testSearchAndOrder1: iQueryRound=0 iItem=0 : map={ecm:pos=0, ecm:uuid=06a9b40d-23e4-4f35-b31b-8095cfb9fcf6}

DocumentModel proxyAttf = proxyFullSubs( modelResultAttfolder1, proxyP.getRef() ); log.debug("testSearchAndOrder1: proxyAttf=" + proxyAttf ); log.debug("testSearchAndOrder1: proxyAttf.isProxy=" + proxyAttf.isProxy() ); log.debug("testSearchAndOrder1: proxyAttf.getFacets=" + proxyAttf.getFacets());

14:00:32,146 DEBUG [FirstDscNXMyTest] testSearchAndOrder1: proxyAttf=DocumentModelImpl(e018c768-f47b-427a-9a78-5baf27494851, path=/testcc1/the_att, title=afWed Aug 15 14:00:31 CEST 2012) 14:00:32,147 DEBUG [FirstDscNXMyTest] testSearchAndOrder1: proxyAttf.isProxy=true 14:00:32,147 DEBUG [FirstDscNXMyTest] testSearchAndOrder1: proxyAttf.getFacets=[Folderish, Orderable]

String queryS = "SELECT " + BuiltinDocumentFields.FIELD_DOC_UUID + " , " + " ecm:pos " + " FROM Document WHERE " + BuiltinDocumentFields.FIELD_DOC_PARENT_REF + " = '" + proxyAttf.getId() + "' " + " and " + BuiltinDocumentFields.FIELD_DOC_TYPE + " = '" + BgiAttachmentsitemDef.ECM_DOC_NAME_MAIN + "' " + " and " + BuiltinDocumentFields.FIELD_DOC_IS_PROXY + " = " + "1 " + " order by ecm:pos "; retDMLIterqr = coreSession.queryAndFetch( queryS, "NXQL" );

log.debug( "testSearchAndOrder1: proxy iQueryRound=" + iQueryRound + " iItem=" + iItem + " : map=" + map );

14:00:32,433 DEBUG [FirstDscNXMyTest] testSearchAndOrder1: proxy iQueryRound=0 iItem=0 : map={ecm:pos=null, ecm:uuid=dcab085b-cd20-4379-94a2-3079b5452f61}

08/15/2012

Orderable is a property of the folder contain the documents, not of the documents themselves.
08/21/2012