Last active
December 11, 2020 12:11
-
-
Save ableasdale/b865e2ad84fdd5872ab8f1050ec7f308 to your computer and use it in GitHub Desktop.
MarkLogic: Manual inspection of a document found in 2 forests in the event of an XDMP-DBDUPURI exception
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 for viewing duplicate document/properties fragment information in situations | |
where MarkLogic Server reports an XDMP-DBDUPURI exception. | |
An XDMP-DBDUPURI will be thrown by MarkLogic in any situation where a document at a given URI | |
appears to exist in more than one forest in a given database; example: | |
XDMP-DBDUPURI: URI /problem/uri.xml found in forests Library06 and Library07 | |
In order to use this script to resolve the issue reported in the above example: | |
$doc would be set to "/problem/uri.xml" | |
$forest-a-name would be set to "Library06" | |
$forest-b-name would be set to "Library07" | |
On execution, the script will return the doc from both forests for manual inspection | |
:) | |
let $doc := "/" (: URI for the document that is found in 2 forests :) | |
let $forest-a-name := "forest_00" (: The first forest reported in the XDMP-DBDUPURI message :) | |
let $forest-b-name := "forest_01" (: The second forest reported in the XDMP-DBDUPURI message :) | |
let $query := | |
'xquery version "1.0-ml"; | |
declare variable $URI as xs:string external; | |
(xdmp:document-properties($URI),fn:doc($URI))' | |
let $options-a := <options xmlns="xdmp:eval"><database>{xdmp:forest($forest-a-name)}</database></options> | |
let $options-b := <options xmlns="xdmp:eval"><database>{xdmp:forest($forest-b-name)}</database></options> | |
let $results-a := xdmp:eval($query,(xs:QName("URI"),$doc),$options-a) | |
let $results-b := xdmp:eval($query,(xs:QName("URI"),$doc),$options-b) | |
return | |
(fn:concat("RESULTS FROM : ", $forest-a-name), $results-a, fn:concat("RESULTS FROM : ", $forest-b-name), $results-b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment