Created
June 11, 2019 18:54
-
-
Save ableasdale/10d5d4bf57ca7ec8611ecb50ab4f90b0 to your computer and use it in GitHub Desktop.
MarkLogic: for a support dump, list the host id and all forest names associated with that host
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"; | |
(: | |
: Get the host/forest configuration | |
:) | |
declare default element namespace "http://marklogic.com/xdmp/status/forest"; | |
declare variable $path as xs:string := '/Users/ableasdale/Downloads/SuppDump20190414'; | |
declare variable $support as document-node()* := xdmp:document-get ( | |
$path, | |
<options xmlns="xdmp:document-get"> | |
<format>xml</format> | |
<repair>full</repair> | |
</options> | |
); | |
declare variable $fs := $support/forest-status; | |
declare function local:get-host-ids() { | |
fn:distinct-values(for $forest in $fs | |
return fn:data($forest/host-id)) | |
}; | |
declare function local:get-forests-by-host($id) { | |
for $forest in $fs where fn:data($forest/host-id) eq $id order by fn:data($forest/forest-name) return (" - "||fn:data($forest/forest-name)) | |
}; | |
for $host in local:get-host-ids() return ($host, local:get-forests-by-host($host)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment