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.

0 votes

2 answers

4453 views

ANSWER



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

1 votes



This tested successfully versioning documents and not versioning them and it getting the expected results. Thanks, Florent!
03/27/2014


hello,

you need to add this clause to filter deleted documents:

ecm:currentLifeCycleState != 'deleted'

Thierry

0 votes



Thanks, I tried that but it still returns an entry for the version that was not deleted. The query results without the ecm:currentLifeCycleState qualifier are below and adding the qualifier removes the second entry but the first entry remains, thus no way to know even with post processing that it's deleted. (included as an answer to format the JSON)

{
"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"
    }
]

}

02/14/2014