Timeout for a loop in XQuery MarkLogic

萝らか妹 提交于 2019-12-01 10:33:41

问题


I have a big collection of about 1 million documents, in MarkLogic (version 9), with below structure:

<File>
    <Id></Id>
    <ModifiedAt></ModifiedAt>
    <Author></Author>
    <Title></Title>
</File>

And I need to iterate through entire collection and to replace space from ModifiedAt with T for all documents

Example of document:

     <File>
         <Id>12121</Id>
         <ModifiedAt>2011-06-08 14:29:29.000</ModifiedAt>
         <Author>Test</Author>
         <Title>Test</Title>
    </File>

Field ModifiedAt should become: 2011-06-08T14:29:29.000

The code looks like:

for $doc in fn:collection('File')
    return xdmp:node-replace($doc/File/ModifiedAt,<ModifiedAt>{fn:replace($doc/File/ModifiedAt,' ','T')}</ModifiedAt>)

The issue is that this code returns timeout.

I assume there is a more elegant way to make this modification on entire collection and maybe someone has a hint.

Thank you!


回答1:


There are various external tools out there, like Corb2, and MLCP that can be used for this, but you can also do adhoc or less adhoc work from inside MarkLogic. All you essentially need to do is do your processing in batches. Taskbot is very useful for that:

https://github.com/mblakele/taskbot

HTH!



来源:https://stackoverflow.com/questions/52935053/timeout-for-a-loop-in-xquery-marklogic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!