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 prop="http://marklogic.com/xdmp/property"; | |
declare variable $doc-count as xs:int := 10; | |
for $item in (1 to $doc-count) | |
let $eval := "xquery version '1.0-ml'; | |
declare variable $count as xs:string external; | |
xdmp:document-insert(fn:concat('/test/', $count, '.xml'), element root{ $count })" | |
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"; | |
for $doc in doc() | |
let $sort-key := xs:dateTime(xdmp:document-properties(fn:base-uri($doc))/prop:properties/prop:last-modified) | |
order by $sort-key | |
return | |
fn:concat("Doc: ", fn:base-uri($doc), " was inserted at: ", $sort-key) |
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"; | |
xdmp:forest-rollback( | |
xdmp:database-forests(xdmp:database("YourDatabase")), | |
xdmp:wallclock-to-timestamp( | |
xs:dateTime("2013-02-28T17:55:07Z"))) |
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"; | |
for $d in doc() | |
return xdmp:document-delete(xdmp:node-uri($d)) |
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"; | |
element groups { | |
for $grp in xdmp:groups() | |
return | |
(element group {attribute id {$grp}, element group-name {xdmp:group-name($grp)}, | |
for $host in xdmp:group-hosts($grp) | |
return element host {attribute id {$host}, xdmp:host-name($host)}, | |
for $server in xdmp:group-servers($grp) | |
return element server {attribute id {$server},xdmp:server-name($server)} |
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
(:::::::::::::: Step one - set up two test databases :::::::::::::::) | |
xquery version "1.0-ml"; | |
import module namespace info = "http://marklogic.com/appservices/infostudio" | |
at "/MarkLogic/appservices/infostudio/info.xqy"; | |
(: Setup test databases :) | |
(info:database-create("source-db", 1), info:database-create("rebalance-me", 8)) | |
(: after completion - confirm that the source-db1 forest contains 200K docs :) |
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
(:::::::::::::: Step two - create content in source-db :::::::::::::::) | |
xquery version "1.0-ml"; | |
(: run against source-db to fill the source forest with 200K docs - may take several minutes to complete :) | |
for $i in 1 to 200000 | |
return xdmp:document-insert(concat($i,".xml"), element node {$i}) |
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
(:::::::::::::: Step four - re-attach source-db-1 forest to rebalance-me database :::::::::::::::) | |
xquery version "1.0-ml"; | |
import module namespace admin = "http://marklogic.com/xdmp/admin" | |
at "/MarkLogic/admin.xqy"; | |
let $config := admin:get-configuration() | |
let $config := admin:database-detach-forest($config, xdmp:database("source-db"), xdmp:forest("source-db-1") ) | |
let $config := admin:database-attach-forest($config, xdmp:database("rebalance-me"), xdmp:forest("source-db-1") ) | |
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
(:::::::::::::: Step five - evacuate source-db-1 forest :::::::::::::::) | |
xquery version "1.0-ml"; | |
xdmp:spawn( | |
"forest-uris-evacuate.xqy", | |
(xs:QName('FOREST'), xdmp:forest('source-db-1'), | |
xs:QName('INDEX'), -1, | |
xs:QName('LIMIT'), 0, | |
xs:QName('RESPAWN'), true()), | |
<options xmlns="xdmp:eval"> |
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
xdmp:spawn( | |
"rebalance-evacuate-forest.xqy", | |
( | |
xs:QName('FOREST'), xdmp:forest('%SOURCE FOREST%'), | |
xs:QName('INDEX'), -1, | |
xs:QName('LIMIT'), 0, | |
xs:QName('RESPAWN'), true() | |
), | |
<options xmlns="xdmp:eval"> | |
<database>{ xdmp:database("%DATABASE NAME%") }</database> |
OlderNewer