marklogicmarklogic-corb

How to setup CORB


How can I construct this XQuery to run in a CORB job? The 2nd module to process each doc with a matching candidate URI is not working.

URIS Module

(:a module to select the candidate URIs to process:)
xquery version "1.0-ml";
declare variable $target-collection := "/activity";  
declare variable $update-collection := "/activity/analytics-read-added"

let $uris := cts:uris( (),
                       (),
                       cts:and-query((          
                           cts:collection-query($target-collection),
                           cts:not-query(cts:collection-query($update-collection))
                        ))
)
return (count($uris), $uris)

Process Module

(:a module to process each doc with a matching candidate URI:)
declare variable $URI as xs:string external;

 xdmp:document-add-permission($URI,xdmp:permission("act-read-role","read")),

xdmp:document-add-collections($URI,$update-collection)

Solution

  • There are a couple of small issues with your process module:

    Applying those changes to the Process module:

    xquery version "1.0-ml";
    (:a module to process each doc with a matching candidate URI:)
    declare variable $URI as xs:string external;
    declare variable $update-collection := "/activity/analytics-read-added";
    
     xdmp:document-add-permissions($URI, xdmp:permission("act-read-role","read")),
     xdmp:document-add-collections($URI, $update-collection)
    

    If you need to troubleshoot and investigate why your Process Module isn't working, it is sometimes easiest to paste the content of the Process Module XQuery into Query Console, assign a value to the $URI variable, and execute in QConsole.

    For example:

    declare variable $URI as xs:string external := "/some/test/doc.xml";