将文件从本地文件系统导入 MarkLogic 时出错

Error while importing a file from a local file system to MarkLogic

我正在尝试将 xml 文件从我的本地文件系统导入 MarkLogic 林。 但是我收到了一些错误。尝试了 xdmp:document-load 个查询的 2 个版本。

第一次查询

xdmp:document-load("C:\Users\admin-rp\Documents\myFile.xml",
   <options xmlns="xdmp:document-load">
      <uri>/myDocs/myDocument.xml</uri>
      <permissions>{xdmp:default-permissions()}</permissions> 
      <collections>{xdmp:default-collections()}</collections> 
      <repair>full</repair>
      <forests>
        <forest>{xdmp:forest("data-hub-FINAL-1")}</forest>
      </forests>
    </options> )

输出

[1.0-ml] XDMP-PLACEKEYSLOCKING: xdmp:document-load("C:\Users\admin-rp\Documents\myFile.xml", <options xmlns="xdmp:document-load"><uri>/myDocs/myDocument.xml</uri>...</options>) -- Fast locking cannot be used with place keys. Stack Trace At line 1 column 1: In xdmp:eval(" xdmp:document-load("C:\Users\admin-rp\Documents\myFile.xml...", (), <options xmlns="xdmp:eval"><database>6682922067126681120</database>...</options>)

  1. xdmp:document-load("C:\Users\admin-rp\Documents\myFile.xml",
  2. <options xmlns="xdmp:document-load">
  3. <uri>/myDocs/myDocument.xml</uri>

第二次查询

xdmp:document-load("C:\Users\admin-rp\Documents\myFile.xml",
  map:map() 
    => map:with("uri", "/documents/myFiles.xml")
    => map:with("permissions", 
                (xdmp:default-permissions("objects"),
                 xdmp:permission("admin", "read", "object")))
    => map:with("collections", ("DDE_ASN_Booking"))
    => map:with("repair", "full")
    => map:with("forests", (xdmp:forest("data-hub-FINAL-1")))

)

输出

[1.0-ml] XDMP-INVOPTVAL: xdmp:document-load("C:\Users\admin-rp\Documents\myFile.xml", map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" .../>)) -- Invalid option value: option 'permissions' has unexpected value '<sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityread</sec:capability> sec:role-id16742763111021671912</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityupdate</sec:capability> sec:role-id3680293911625886504</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityread</sec:capability> sec:role-id3680293911625886504</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityupdate</sec:capability> sec:role-id5126952842460325403</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityread</sec:capability> sec:role-id7089338530631756591</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityupdate</sec:capability> sec:role-id7066700860632287285</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityread</sec:capability> sec:role-id7066700860632287285</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityupdate</sec:capability> sec:role-id15520654661378671735</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityupdate</sec:capability> sec:role-id2950849599482623662</sec:role-id> </sec:permission> <sec:permission xmlns:sec="http://marklogic.com/xdmp/security"> sec:capabilityread</sec:capability> sec:role-id17774220447394382090</sec:role-id> </sec:permission> {"capability":"read", "roleId":"8487823278258687528"}' Stack Trace At line 1 column 0: In xdmp:eval("xdmp:document-load("C:\Users\admin-rp\Documents\myFile.xml&...", (), <options xmlns="xdmp:eval"><database>6682922067126681120</database>...</options>)

  1. xdmp:document-load("C:\Users\admin-rp\Documents\myFile.xml",
  2. map:map() => map:with("uri", "/documents/myFiles.xml")
  3. => map:with("permissions",

============================================= =====

任何人都可以查看并建议我在这两种情况下到底缺少什么吗?

在第一个实例中,对于 XDMP-PLACEKEYSLOCKING 错误,您是在告诉它要插入文档的林,而不是让数据库根据分配策略来决定文档应该位于哪个林中。

https://docs.marklogic.com/guide/ingestion/xquery#id_24146

In order to load a document into a forest by explicitly specifying a forest key, the forest must exist and be attached to the database into which you are loading. Attempting to load a document into a forest that does not belong to the context database will throw an exception. Additionally, the locking parameter must be set to strict on the database configuration, otherwise an XDMP-PLACEKEYSLOCKING exception is thrown.

如果您将锁定设置为 fast 并尝试将文档分配给特定的林,您将收到该错误。您需要将锁定设置为 strict,以确保集群中的节点在事务完成时获得分发的时间戳,并且另一个竞争事务没有机会将具有相同 URI 的文档放入不一样的森林。 https://help.marklogic.com/knowledgebase/article/View/243/0/fast-vs-strict-locking

在您的第二次尝试中,XDMP-INVOPTVAL 错误告诉您选项 permissions 的值无效。

查看 permission 序列中的两项,返回的权限来自:

xdmp:default-permissions("objects")

格式为“元素”,而非“对象”。您似乎希望将格式指定为“对象”而不是指定 URI。但是,如果您没有第一个参数的内容,它将假设您正在尝试获取“对象”(第一个参数)的 URI 的默认权限。

为第一个参数使用空序列,以便它 returns 该用户的默认权限:

xdmp:default-permissions((), "objects")

xdmp:default-permissions()

的第二个示例中记录了这一点