MarkLogic Server 11.0 Product Documentation
POST /v1/config/server

Summary

Apply changes to the configuration of the server specified by a request payload that declares chained and nested calls to the Admin API.

Request Headers
Content-Type? The MIME type of the request body. Allowed values:
  • application/vnd.marklogic.configdsl+javascript for calls to the Admin API represented in JavaScript syntax
  • application/json for calls to the Admin API serialized as an AST (Abstract Syntax Tree) in JSON format

Response

Upon success, MarkLogic Server responds with a 200 (OK) status and any output from the Admin API calls, setting the Content-Type response header as follows:

Required Privileges

This operation requires the manage-user role (either directly or through inheritance as with the manage role) or the http://marklogic.com/xdmp/privileges/manage privilege.

In addition, the functions of the Admin API require additional privileges that are specific to those functions.

Usage Notes

The /v1/config/server endpoint accepts a request payload that declares calls to the Admin API functions. The payload can be provided either as an AST (Abstract Syntax Tree) in JSON syntax or as a DSL (Domain Specific Language) in JavaScript syntax. Any output from processing the declaration is returned as the response payload.

The Config DSL provides a declaration of configuration for editing by people.

The Config AST provides a declaration of configuration for generation and manipulation by scripts, tools, and APIs.

For more information about the Admin API, see Using the Admin API in the Scripting Administrative Tasks Guide.

Example

$ cat ./configdsl.js
const db = xdmp.database('Documents');
$a.databaseSetFastCaseSensitiveSearches(db, true)
  .databaseSetFastDiacriticSensitiveSearches(db, true)
  .databaseSetFastPhraseSearches(db, false)
  .saveConfiguration();

$ curl --anyauth --user user:password -X POST -d@'./configdsl.js' -i \
  -H "Content-Type: application/vnd.marklogic.configdsl+javascript" \
  http://localhost:8000/v1/config/server

==> MarkLogic Server changes the search configuration for the Documents database.

HTTP/1.1 200 OK
Content-type: text/plain; charset=utf-8
Server: MarkLogic
Content-Length: 47
Connection: Keep-Alive
Keep-Alive: timeout=5

script run on 2022-02-14T10:54:26.612834-08:00
  

Example

$ cat ./configast.json
    {"$config":[
        {"ns":"op", "fn":"constdefs", "args":[
          {"name":"db",  "value":{"ns":"xdmp",  "fn":"database",          "args":["Documents"]}},
          {"name":"cfg", "value":{"ns":"admin", "fn":"get-configuration", "args":[]}},
          {"name":"out", "value":{"ns":"map",   "fn":"entry",             "args":[
            "phrase",
            {"ns":"admin", "fn":"database-get-fast-phrase-searches", "args":[
              {"ns":"op", "fn":"constref", "args":["cfg"]},
              {"ns":"op", "fn":"constref", "args":["db"]}
              ]}
            ]}}
          ]},
        {"ns":"op", "fn":"constref", "args":["out"]}
        ]}

$ curl --anyauth --user user:password -X POST -d@'./configast.json' -i \
  -H "Content-Type: application/json" \
  http://localhost:8000/v1/config/server

==> MarkLogic Server reads the search configuration for the Documents database.

HTTP/1.1 200 OK
Content-type: application/json; charset=utf-8
Server: MarkLogic
Content-Length: 16
Connection: Keep-Alive
Keep-Alive: timeout=5

{"phrase":false}
Powered by MarkLogic Server | Terms of Use | Privacy Policy