Listing all collections without a collection lexicon

sysadminIf you need to view all of the collections available in a MarkLogic database without a collection lexicon enabled, you can execute the following XQuery:

fn:distinct-values(for $c in for $d in xdmp:directory(“/”, “infinity”) return xdmp:document-get-collections(xdmp:node-uri($d)) return $c)

To get a list of all of the XPaths available, you can use:

fn:distinct-values(for $d in xdmp:directory(“/”, “infinity”) return fn:replace(xdmp:node-uri($d), “[^/]+$”, “”))