MarkLogic 如何在指定森林中插入文档

时间:2021-07-02 00:16:29

标签: marklogic

我的数据库中有重复的 URI。我想通过在我的 test-dup 数据库的不同林中复制具有相同 URI 的问题来进行测试,但是 它会排除错误。看起来我无法在森林中分配 URI。

<块引用>

1.0-ml] XDMP-PLACEKEYSLOCKING: xdmp:document-insert("/xquery/catalog.xml", 557........., (), (), 0, (xs:unsignedLong( "13222250964842568399"), xs:unsignedLong("15490631252765310070"))) -- 快速锁定不能与位置键一起使用。

xquery version "1.0-ml";
let $XML:=<catalog>
             <product dept="WMN">
             <number>557</number>
             <name language="en">Fleece Pullover</name>
             <colorChoices>navy black</colorChoices>
</product>
let $filename:= "/xquery/catalog.xml"
return
xdmp:document-insert($filename,$XML,(),(),0,xdmp:database-forests(xdmp:database("test-dup")) )

1 个答案:

答案 0 :(得分:0)

您的数据库时间戳是否设置为“快速”?

<块引用>

为了通过显式指定森林键将文档加载到森林中,森林必须存在并附加到您要加载到的数据库中。尝试将文档加载到不属于上下文数据库的林中将引发异常。 另外,数据库配置上的locking参数必须设置为strict,否则会抛出XDMP-PLACEKEYSLOCKING异常。

如果您将其更改为 strict,那么您将不会看到错误,但仍然不会出现重复项。

复制重复文档问题的一种简单方法是:

  1. 确保重新平衡器被禁用
  2. 分离其中一个 test-dup 森林(即 test-dup1)
  3. 插入您的文档
  4. 分离它插入的森林(即 test-dup2)
  5. 重新附加 test-dup1 森林
  6. 再次插入文档
  7. 同时附加 test-dup1 和 test-dup2 森林

您现在将拥有相同 URI 的重复文档,因为它将同时存在于 test-dup1 和 test-dup2 森林中。

相关问题