Last active
April 15, 2020 12:08
-
-
Save ableasdale/dc7fa570a5be9a93f767b394580686b2 to your computer and use it in GitHub Desktop.
MarkLogic: Parse a support dump, extract all databases in order and create an unordered list containing their configured element range indexes
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"; | |
| declare namespace db = "http://marklogic.com/xdmp/database"; | |
| declare variable $path as xs:string := 'e:\Downloads\support_dump.txt'; | |
| declare variable $support as document-node()* := xdmp:document-get( | |
| $path, | |
| <options xmlns="xdmp:document-get"> | |
| <format>xml</format> | |
| <repair>full</repair> | |
| </options> | |
| ); | |
| xdmp:save("e:\element-range-indexes.html", | |
| element html { | |
| element body { | |
| let $databases := for $db in fn:distinct-values($support//*:database-name) | |
| order by $db ascending | |
| return subsequence(($support//db:database[db:database-name eq $db]),1,1) | |
| for $db in $databases | |
| where fn:exists($db/db:range-element-indexes/db:range-element-index) | |
| return (element h2 {fn:data($db/db:database-name)}, element ul { for $idx in $db/db:range-element-indexes/db:range-element-index order by fn:data($idx/db:localname/string(.)) ascending return element li {fn:data($idx/db:localname)}}) | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment