Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created February 15, 2016 08:58
Show Gist options
  • Select an option

  • Save ableasdale/6e9c0aad010d6138f8d8 to your computer and use it in GitHub Desktop.

Select an option

Save ableasdale/6e9c0aad010d6138f8d8 to your computer and use it in GitHub Desktop.
Reordering forests for the rebalancer after adding more hosts to a cluster.
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
admin:save-configuration(
admin:database-reorder-forests($config, $dbid,
(for $i in xdmp:database-forests(xdmp:database($DATABASE))
let $fname := xdmp:forest-name($i)
order by number(substring-before(substring-after($fname, "n"),"-"))
return ($i))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment