马克逻辑: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 作为输入,并进行相应的处理。这允许在没有超时的情况下处理非常大的批处理。
关于xquery - MarkLogic:处理文档以添加属性超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65103518/