I am trying to get the list of forests and its data directory in a particular host/node can anyone help me with a query?
You can obtain the list of forests from the xdmp:host-status()
, look for the h:assignment
that have the specified h:host-id
, and then use the forest-id
of each forest to fetch the xdmp:forest-status()
to obtain the data-dir
for each forest.
declare namespace h = "http://marklogic.com/xdmp/status/host";
declare namespace f = "http://marklogic.com/xdmp/status/forest";
let $host := xdmp:host()
for $forest-id in xdmp:host-status($host)/h:assignments/h:assignment[h:host-id = $host]/h:forest-id/data()
return
<f:forest>{
xdmp:forest-status($forest-id)/(f:forest-name, f:data-dir)
}</f:forest>