| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 5:59 AM | XQuery & XSLT Built-In & Modules Function Reference
Module: Admin Library - Actions Functions
The Admin module is an XQuery library module that allows you to script administrative tasks that you otherwise would need the Admin Interface to perform. Most functions in this library perform adminstrative tasks and therefore require the user who runs the XQuery program to have the Admin role. Many of these functions provide new configuration information. In most cases, you must save the configuration (with `admin:save-configuration`, for example) in the same statement that you use the functions in order for them to take effect. To use the Admin module as part of your own XQuery module, include the following line in your XQuery prolog: `import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy" ;` The library namespace prefix `admin` is not predefined in the server.
Function Summary
admin:get-configuration | Loads the admin configuration into memory for use by other functions in the Admin module.
admin:restart-hosts | This function restarts MarkLogic Server for the specified hosts.
admin:save-configuration | This function saves a configuration specification to the cluster configuration files.
admin:save-configuration-without-restart | This function saves a configuration specification to the cluster configuration files, without restarting MarkLogic Server.
Function Detail
admin:get-configuration( ) as element(configuration)
Summary: Loads the admin configuration into memory for use by other functions in the Admin module.
Required Privilege: `http://marklogic.com/xdmp/privileges/admin-module-read`
Usage Notes: The configuration is loaded into memory only as it is needed, so it might not contain the entire configuration at any given moment. It loads only the parts of the configuration that are needed at the time they are needed to perform other Admin module operations that specified in the XQuery request. Therefore, if you execute the function without calling any other Admin module functions, it will return the empty sequence (because it never needed any of the config information to perform any of the Admin module operations).
Example:
      xquery version "1.0-ml";

      import module namespace admin = "http://marklogic.com/xdmp/admin"
    		  at "/MarkLogic/admin.xqy";

       let $config := admin:get-configuration()
       return
       admin:database-get-range-element-indexes($config,
                               xdmp:database("Documents") )

      => The xml for any element range indexes in the "Documents"
         database, for example:
       <range-element-index xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	                xmlns="http://marklogic.com/xdmp/database">
          <scalar-type>date</scalar-type>
          <collation/>
          <namespace-uri>mynamespace</namespace-uri>
          <localname>myelementname</localname>
          <range-value-positions>false</range-value-positions>
       </range-element-index>
admin:restart-hosts(
| $hosts as xs:unsignedLong*
) as empty-sequence()
Summary: This function restarts MarkLogic Server for the specified hosts.
Parameters:
$hosts : The host ID(s) for the host(s) you want to restart. For example, `xdmp:host()` returns the ID for the current host.
Example:
    (:
      This query restarts all hosts in the cluster.  Note that
      it will restart the host in which the query is run, too.
    :)
    xquery version "1.0-ml";

    import module namespace admin = "http://marklogic.com/xdmp/admin"
    at "/MarkLogic/admin.xqy";
    declare namespace host="http://marklogic.com/xdmp/status/host";

    let $hostids :=
       for $id in xdmp:host-status(xdmp:host())
                                   /host:hosts//host:host/host:host-id
       return fn:data($id)
    return
    admin:restart-hosts($hostids)
admin:save-configuration(
| $config as element(configuration)
) as empty-sequence()
Summary: This function saves a configuration specification to the cluster configuration files. It restarts MarkLogic Server for "cold" administrative tasks only (for example, for App Server port assignment changes). If you do not want those "cold" administrative tasks to automatically restart MarkLogic Server, use `admin:save-configuration-without-restart` instead.
Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
Required Privilege: `http://marklogic.com/xdmp/privileges/admin-module-write`
Example:
      xquery version "1.0-ml";

      import module namespace admin = "http://marklogic.com/xdmp/admin"
    		  at "/MarkLogic/admin.xqy";

      let $config := admin:get-configuration()
      let $spec := admin:forest-set-enabled($config,
        xdmp:forest("myForest"), fn:true() )
      return
      admin:save-configuration($spec)
admin:save-configuration-without-restart(
| $config as element(configuration)
) as xs:unsignedLong*
Summary: This function saves a configuration specification to the cluster configuration files, without restarting MarkLogic Server. If you use this function to save any changes that require a server restart ("cold" changes such as App Server port assignment changes), then the changes will not take effect until the next time MarkLogic Server restarts (although they will be saved in the configuration). If you want MarkLogic Server to automatically restart when needed, use `admin:save-configuration` instead.
Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
Required Privilege: `http://marklogic.com/xdmp/privileges/admin-module-write`
Usage Notes: The return value is a list of the host IDs that need to be restarted in order for the changes to take effect.
Example:
      xquery version "1.0-ml";

      import module namespace admin = "http://marklogic.com/xdmp/admin"
    		  at "/MarkLogic/admin.xqy";

      let $config := admin:get-configuration()
      let $spec := admin:forest-set-enabled($config,
        xdmp:forest("myForest"), fn:true() )
      return
      admin:save-configuration-without-restart($spec)

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.