Last active
January 11, 2017 13:20
-
-
Save ableasdale/818dd407bcf2fc5e0282ad41dcf39626 to your computer and use it in GitHub Desktop.
MarkLogic: Simple Example of a bulk delete of documents from a URI query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
declare variable $TARGET-DIRECTORY as xs:string := "/"; | |
declare variable $TARGET-DATABASE as xs:string := "YourDatabaseName"; | |
declare variable $BATCH-SIZE as xs:integer := 20000; | |
for $uri in cts:uris("", ("document", "limit="||$BATCH-SIZE), cts:directory-query($TARGET-DIRECTORY)) | |
return | |
xdmp:eval( | |
"declare variable $URI as xs:string external; | |
xdmp:document-delete($URI)", | |
(xs:QName("URI"), $uri), | |
<options xmlns="xdmp:eval"> | |
<isolation>different-transaction</isolation> | |
<prevent-deadlocks>true</prevent-deadlocks> | |
<database>{xdmp:database($TARGET-DATABASE)}</database> | |
</options>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment