NXQL filtering out deleted documents
Hi,
I have the NXQL query below being executed via Resultset.PageProvider REST call
{ "params": { "pageSize" : 100, "query" : "SELECT ecm:uuid, dc:title, ecm:primaryType, ecm:isLatestVersion, ecm:isCheckedInVersion, ecm:versionVersionableId, ecm:currentLifeCycleState, file:content/mime-type FROM Picture " } }
If the document has been edited then an object is returned for each version. Adding
where ecm:isLatestVersion = 1 or ecm:isLatestVersion is null
returns the latest version and the deleted version and the versions can be linked by matching the deleted version's ecm:uuid property with the non-deleted ecm:versionVersionableId but it seems error prone and is not documented.
Can an NXQL query be structured so documents in a deleted state are not returned without client-side post-processing?
Thanks in advance.
Try using ecm:isVersion = 0
(or the more verbose ecm:isCheckedInVersion = 0
before Nuxeo 5.8) to only get the “live” document, instead of ecm:isLatestVersion
which deals with versions
hello,
you need to add this clause to filter deleted documents:
ecm:currentLifeCycleState != 'deleted'
Thierry
{
"entity-type": "recordSet",
"isPaginable": true,
"resultsCount": 2,
"pageSize": 100,
"maxPageSize": 100,
"currentPageSize": 2,
"currentPageIndex": 0,
"numberOfPages": 1,
"isPreviousPageAvailable": false,
"isNextPageAvailable": false,
"isLasPageAvailable": false,
"isSortable": true,
"hasError": false,
"errorMessage": null,
"entries": [
{
"ecm:currentLifeCycleState": "project",
"ecm:primaryType": "Picture",
"ecm:uuid": "96c34688-f97e-404b-ba56-a6e953e51dc6",
"ecm:isCheckedInVersion": true,
"file:content/mime-type": "image/jpeg",
"ecm:versionVersionableId": "467320ab-d3de-491f-86ad-cd30f75cbb4c",
"ecm:isLatestVersion": true,
"dc:title": "Deleted Picture"
},
{
"ecm:currentLifeCycleState": "deleted",
"ecm:primaryType": "Picture",
"ecm:uuid": "467320ab-d3de-491f-86ad-cd30f75cbb4c",
"ecm:isCheckedInVersion": null,
"file:content/mime-type": "image/jpeg",
"ecm:versionVersionableId": null,
"ecm:isLatestVersion": null,
"dc:title": "Deleted Picture"
}
]
}