Create a new forest, including replicas if specified. If a database id or database is included, attach the new forest(s) to the database. For an example, see Preliminary Configuration Procedures in the Scripting Administrative Tasks Guide.
Upon successful completion, MarkLogic Server returns status code 201 (Created).
manage-user
rolehttp://marklogic.com/xdmp/privileges/manage
manage
role plus one of the following granular privileges:
http://marklogic.com/xdmp/privileges/admin/forest
http://marklogic.com/xdmp/privileges/admin/forest/forest-ID
The payload can specify either replica forests or failover hosts, but not both. If replicas are specified in the POST body, then replication is enabled by default.
Newly created forests are enabled by default.
Setting range boundaries for the forest in the POST body does not modify the configuration of the database to which the forest is attached.
The structure of the data in the POST body is shown below. You
must include at least forest-name
and host
. If replicas are
included, the configuration data for each replica must include at least
replica-name
and host
.
Note: The properties described
here are for XML payloads. In general they are the same for JSON, with the exception that,
in JSON, failover-hosts
and forest-replicas
are expressed in
singular form. For example, in JSON, failover-hosts
is instead
failover-host
and the format is: "failover-host":["hostname"]
.
The data in the POST body must be valid according to the schema type "forest-properties" in the "manage-forest-properties.xsd" schema. JSON payloads are internally converted to XML before validation.
forest-name
host
database
data-directory
large-data-directory
fast-data-directory
availability
rebalancer-enable
range
This is a complex structure with the following children:
lower-bound
upper-bound
failover-hosts
This is a complex structure with the following children:
failover-host
failover-enable
forest-backups
This is a complex structure with the following children:
forest-backup
This is a complex structure with the following children:
backup-id
backup-enabled
backup-directory
backup-type
backup-period
backup-month-day
backup-days
This is a complex structure with the following children:
backup-day
backup-start-date
backup-start-time
backup-timestamp
forest-replicas
This is a complex structure with the following children:
forest-replica
This is a complex structure with the following children:
replica-name
host
data-directory
large-data-directory
fast-data-directory
database-replication
updates-allowed
enabled
$ cat forest-create.xml ==> <forest-create xmlns="http://marklogic.com/manage"> <forest-name>example-1</forest-name> <host>my-host</host> </forest-create> $ curl --anyauth --user user:password -X POST -d @./forest-create.xml \ -i -H "Content-type: application/xml" \ http://localhost:8002/manage/v2/forests ==> Create a forest named "example-1" on host "my-host". MarkLogic Server responds with output similar to the following. You can use the reference in the Location header to retrieve status and other information about the new forest. HTTP/1.1 201 Created Location: /manage/v2/forests/2721944172534009539 Content-type: application/xml Cache-Control: no-cache Expires: -1 Server: MarkLogic Content-Length: 0 Connection: Keep-Alive Keep-Alive: timeout=5
$ cat forest-create.json ==> { "forest-name": "example-2", "host": "my-host", "database": "Documents" } $ curl --anyauth --user user:password -X POST -d @./forest-create.json \ -i -H "Content-type: application/json" \ http://localhost:8002/manage/v2/forests ==> Create a forest named "example-2" on host "my-host", and attach it to the Documents database. MarkLogic Server responds with headers similar to the following. You can use the reference in the Location header to retrieve status and other information about the new forest. HTTP/1.1 201 Created Location: /manage/v2/forests/2721944172534009539 Content-type: application/xml Cache-Control: no-cache Expires: -1 Server: MarkLogic Content-Length: 0 Connection: Keep-Alive Keep-Alive: timeout=5
$ curl --anyauth --user admin:admin -X POST \ -d '{"forest-name": "Documents", "host": "host-1.marklogic.com", "database": "Master", \ "forest-replicas": {"forest-replica":[{"replica-name": "Documents-R", "host": "host-3.marklogic.com"}]}}' \ -i -H "Content-type: application/json" http://localhost:8002/manage/v2/forests ==> Creates a "Documents" forest on "host-1" with a "Documents-R" replica forest on "host-3." Note that both hosts must be in the same cluster.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.