简体   繁体   中英

How to save a list of URIs matching a pattern in Marklogic with corb?

I need some help with MarkLogic, XQuery & corb,

I have millions of documents in the database, I'm trying to write the XQuery to saved the matched uris.

urisVersions.xqy

xquery version "1.0-ml";
let $uris := cts:uri-match("*versions/*version-*")

return (fn:count($uris), $uris)

urisSave.xqy

xquery version "1.0-ml";
declare variable $URI as xs:string external;

let $uri := $URI 
return xdmp:save("/tmp/test",$uri)

save-job.properties

XCC-CONNECTION-URI= xcc://user:admin@localhost:8000/
URIS-MODULE=urisVersions.xqy|ADHOC
XQUERY-MODULE=urisSave.xqy|ADHOC
THREAD-COUNT=10

Getting below error SEVERE: fatal error com.marklogic.developer.corb.CorbException: Invalid argument type at URI: /12312/versions/item/papkov.xml.version-24

Can anyone please help me to solve this issue?

Configure the job with thePROCESS-TASK option to use the com.marklogic.developer.corb.ExportBatchToFileTask class, which will write the results of each process module invocation to an output file. You can configure where to write the file and the filename with EXPORT-FILE-NAME and EXPORT-FILE-DIR options. If you don't configure the EXPORT-FILE-DIR and just give it a filename with EXPORT-FILE-NAME it writes relative from where CoRB is launched.

PROCESS-TASK=com.marklogic.developer.corb.ExportBatchToFileTask
EXPORT-FILE-NAME=versionsURIs.txt

Change your process module to simply return the $URI value:

xquery version "1.0-ml";
declare variable $URI as xs:string external;
$URI

If you just want to write the URIs to a file and aren't transforming or doing any processing, then you could use the ModuleExecutor class and have it write the results of the cts:uri-match directly to the output file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM