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"; | |
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; | |
declare variable $DATABASE as xs:string := "example-db"; | |
let $config := admin:get-configuration() | |
let $dbid := admin:database-get-id($config, $DATABASE) | |
return |
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"; | |
(: See http://docs.marklogic.com/REST/POST/manage/v2/databases/%5Bid-or-name%5D :) | |
declare variable $payload-status := '{"operation": "backup-database", "forest": ["Documents"], "backup-dir": "/tmp" }'; | |
xdmp:http-post("http://localhost:8002/manage/v2/databases/Documents?format=json", | |
<options xmlns="xdmp:http"> | |
<authentication method="digest"> | |
<username>username</username> |
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"; | |
(: See http://docs.marklogic.com/REST/POST/manage/v2/databases/%5Bid-or-name%5D :) | |
declare variable $payload-status := '{"operation": "backup-status", "job-id" : "' || "12979282468857286095" || '","host-name": "' || xdmp:host-name() || '"}'; | |
xdmp:http-post("http://localhost:8002/manage/v2/databases/Documents?format=json", | |
<options xmlns="xdmp:http"> | |
<authentication method="digest"> | |
<username>username</username> |
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 f = "http://marklogic.com/xdmp/status/forest"; | |
declare variable $DATABASE as xs:string := xdmp:get-request-field("db", "Documents"); | |
declare function local:create-bootstrap-page($title as xs:string, $content as element()){ | |
element html { attribute lang {"en"}, | |
element head { | |
element meta { attribute charset {"utf-8"}}, |
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 variable $chunk as xs:integer := 1000; | |
declare variable $count as xs:unsignedLong := xdmp:eager(fn:count( cts:uris( (), (), (), (), () ))); | |
declare variable $loop as xs:unsignedLong := xs:integer(fn:ceiling ( $count ) div $chunk) + 1; | |
declare variable $option as element() := | |
<options xmlns="xdmp:eval"> | |
<transaction-mode>update-auto-commit</transaction-mode> | |
</options>; |
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 function local:doWork( $cnt as xs:integer, $start as xs:integer, $end as xs:integer, $uris as xs:string* ){ | |
xdmp:log(fn:concat("permission-change database:" , " total-cnt:", $cnt, " start:", $start, " end:", $end, " start:", xdmp:eval("fn:current-time()"))), | |
for $i in $uris return xdmp:document-set-permissions($i,xdmp:permission("read-only","read")), | |
xdmp:commit(), | |
xdmp:log(fn:concat("permission-change database: ", " total-cnt:", $cnt, " start:", $start, " end:", $end, " finished:", xdmp:eval("fn:current-time()"), " Elapsed:", xdmp:elapsed-time() )) | |
}; |
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
declare function local:update($map, $key, $num) { | |
let $key := fn:tokenize($key, "-")[3] | |
let $e := ( map:get($map, $key), 0) [1] | |
return map:put($map, $key, $e + $num) | |
}; | |
let $map:= map:map() | |
let $_ := |
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
element table { attribute border {1}, | |
element tr { element th {"Source"}, element th {"Active"}, element th {"Deleted"}, element th {"Rebalancing"}, element th {"Total to be moved"}}, | |
for $f in xdmp:document-get("/path/to/result.xml")/result/*:forest-counts | |
return | |
element tr { element td {$f/*:forest-name/fn:string(.)} , element td {fn:sum ($f//*:active-fragment-count)}, | |
element td {fn:sum ($f//*:deleted-fragment-count)}, | |
element td { | |
fn:string-join( | |
for $c in $f//*:rebalance-fragment-count[*:fragment-count != 0] return ($c/*:rebalance-destination || ": " || $c/*:fragment-count), " | ")}, | |
element td {fn:sum($f//*:rebalance-fragment-count[*:fragment-count != 0]/*:fragment-count)}} |
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"; | |
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; | |
let $config := admin:get-configuration() | |
let $appServer := admin:appserver-get-id($config, admin:group-get-id($config, "Default"), "DemoAppServer") | |
return admin:appserver-get-ssl-client-certificate-authorities($config, $appServer) |
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"; | |
import module namespace pki = "http://marklogic.com/xdmp/pki" at "/MarkLogic/pki.xqy"; | |
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; | |
declare namespace x509 = "http://marklogic.com/xdmp/x509"; | |
let $config := admin:get-configuration() | |
let $groupid := admin:group-get-id($config, "Default") | |
let $appservid := admin:appserver-get-id($config, $groupid, "DemoAppServer") |