Created
December 11, 2020 12:19
-
-
Save ableasdale/569a4e1fbf54c85a510ccedf9437d9c5 to your computer and use it in GitHub Desktop.
MarkLogic: Delete one document after inspecting both duplicates in the event of an XDMP-DBDUPURI
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"; | |
(: | |
A Utility module to allow the deletion of a fragment in a given forest in the event of | |
an XDMP-DBDUPURI exception. | |
Given the following exception: | |
XDMP-DBDUPURI: URI /problem/uri.xml found in forests Library06 and Library07 | |
$doc would be set to "/problem/uri.xml" | |
$forest-name would be set to either "Library06" or "Library07" on inspecting the document in both forests. | |
:) | |
let $doc := "/" (: URI for the document that is found in 2 forests :) | |
let $forest-name := "forest_00" (: The name of the forest from which the document should be removed :) | |
let $query := | |
'xquery version "1.0-ml"; | |
declare variable $URI as xs:string external; | |
xdmp:document-delete($URI)' | |
let $options := <options xmlns="xdmp:eval"><database>{xdmp:forest($forest-name)}</database></options> | |
return xdmp:eval($query,(xs:QName("URI"),$doc),$options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment