Marklogic 使用corb将CSV文件加载到包含集合的内容数据库中

Marklogic 使用corb将CSV文件加载到包含集合的内容数据库中,marklogic,marklogic-corb,Marklogic,Marklogic Corb,我的本地文件夹中有一个CSV文件。我想使用CoRB将该文件加载到MarkLogicDB的指定集合中。您能提供帮助吗?您可能希望将作业配置为使用指向CSV的选项。CORB将读取文件并将CSV中的每一行发送到配置为要处理的$URI值的 属性文件的外观如下所示: # how to connect to to the XCC server XCC-CONNECTION-URI=xcc://user:password@localhost:8202/ # path to the CSV file to be

我的本地文件夹中有一个CSV文件。我想使用CoRB将该文件加载到MarkLogicDB的指定集合中。您能提供帮助吗?

您可能希望将作业配置为使用指向CSV的选项。CORB将读取文件并将CSV中的每一行发送到配置为要处理的
$URI
值的

属性文件的外观如下所示:

# how to connect to to the XCC server
XCC-CONNECTION-URI=xcc://user:password@localhost:8202/
# path to the CSV file to be processed
URIS-FILE=input-uris.csv 
# the module that will process and save each CSV row
PROCESS-MODULE=save-row.xqy|ADHOC
# how many threads to use to execute process modules
THREAD-COUNT=10 
在流程模块中,您需要声明一个名为
$uri
的外部变量,然后用分隔符在CSV行上标记并处理数据列。调用以插入文档并指定要将文档放入的集合:

xquery version "1.0-ml";

declare variable $URI as xs:string external;

let $columns := fn:tokenize($URI, ",\s?")
(: assuming that the first column has a unique value to be used for the URI :)
let $uri := $columns[1]
(:do whatever processing you would need to generate the document from CSV columns :)
let $content := $columns[2] 
return 
  xdmp:document-insert($uri,
    $content, 
    map:map() => map:with("collections", "mySpecialCollection")
  )
注意:xdmp:document-insert()的签名最近已更改。现在,您可以在第三个参数的map或options元素中指定
xdmp:document insert
选项,例如权限和集合。在以前的MarkLogic版本中,权限和集合是第三个和第四个参数。根据您正在使用的MarkLogic版本调整对
xdmp:document-insert()
的调用(文档左上方有一个下拉列表,用于选择您的版本)