xquery - MarkLogic:处理文档以添加属性超时

标签 xquery marklogic

马克逻辑:9.8.0

我们有大约 20M 的数据,现在我们需要将额外的数据添加到文档属性中。

所以我们已经设置了调度程序,下面的代码将被执行

let $Log := xdmp:log("[ Project ][ Scheduler ][ Start ][ ======================== Insert Records Scheduler Start ======================== ]")

for $author in (/author][not(property::root/contributors)])[1 to 500]

let $uri           := $author/base-uri()
let $auth_element  := if ($author/aug)
                      then
                           for $auth in $author/aug/pname
                               let $snm := $auth/snm/text()
                               let $fnm := fn:concat(fn:string-join(for $i in $auth/fnm return $i,' '),'')
                               return
                                     <pname type='author'>{fn:normalize-space(fn:concat($snm,' ',$fnm))}</pname>
                      else if ($author/editg)
                      then
                           for $auth in $author/pname
                               let $snm := $auth/snm/text()
                               let $fnm := fn:concat(fn:string-join(for $i in $auth/fnm return $i,' '),'')
                               return
                                     <pname type='editor'>{fn:normalize-space(fn:concat($snm,' ',$fnm))}</pname>
                      else ()
let $XmlDoc := <root><contributors>{$auth_element}</contributors></root>             
        
return try{
            xdmp:document-add-properties($uri,$XmlDoc),
            xdmp:log("[ InspecDirect ][ Scheduler ][ End ][ ======================== Insert Records Scheduler End ======================== ]")
            }
       catch($e){xdmp:log($e)}

当我们从 [1 到 500] 更改为 [1 到 10000] 时,我们会在此处收到超时错误。 如果我们选择 500 个,那么将需要数周时间才能完成。

能否请您告诉我这种方法是否可行?

最佳答案

Corb2可能是更好的解决方案。您可以将当前的 XQuery 分成两部分。第一部分将收集需要更新的 URI。

第二部分将 URI 作为输入,并进行相应的处理。这允许在没有超时的情况下处理非常大的批处理。

Corb2 Wiki

Corb2 Github

关于xquery - MarkLogic:处理文档以添加属性超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65103518/

相关文章:

xpath - xquery 返回 bool 值是否节点存在于某个位置

xml - 如何在 XQuery 中打开字符串?

marklogic - 学习 Marklogic 基础知识的方法

node.js - 使用 marklogic Nodejs API 阅读大型文档

xpath - Xquery通过在运行时传递父值来获取子节点

xquery - 如何检查xml中的属性可用性?

xpath - Marklogic - 如何处理 XML 中的处理指令

xquery - 当我尝试更新节点时,出现错误 "Cannot Update constructed nodes"

xpath 在同级集合中导航文档

node.js - Marklogic Node API - 如何过滤 valueBuilder 的结果