1

MarkLogic 版本 9.0-6.2

mlcp 版本 9.0.6

我有一个客户集合,每个文档都有一个客户根节点,如下所示。

<customer>
  <customerId>123</customerId>
  ....
</customer>

我需要将集合中的所有文档导出到一个名为 customerinfo 的新根目录下的单个输出文件中

<customerInfo>
    <customer>
      <customerId>123</customerId>
      ....
    </customer>
    <customer>
      <customerId>456</customerId>
      ....
    </customer>
</customerInfo>

使用下面的代码,我可以将集合导出为目录下的单个文档。

mlcp.sh export -ssl \
-host localhost \
-port 8010 \
-username uname \
-password pword \
-mode local \
-output_file_path /test/TestFiles/customer \
-collection_filter customer \
-output_type document

是否可以在一个新的根节点下将输出聚合到一个文档中?

4

2 回答 2

0

不,mlcp 可以在导入过程中转换文档,但不能在导出过程中。不过,在 XQuery 中将查询结果合并到单个文档中相当简单:

xdmp:save('/test/TestFiles/customer/merged.xml',
  <root>{ collection('customer') }</root>
)

您还可以查看其他 MarkLogic 工具,例如corbData Movement SDK

于 2019-02-10T21:40:54.343 回答
0

ml-gradle 有一些使用 MarkLogic 的数据移动 SDK 的任务,因此理想情况下您不需要编写任何代码来执行此操作 - https://github.com/marklogic-community/ml-gradle/wiki/Exporting-data

于 2019-02-12T14:12:18.563 回答