MarkLogic 12 EA 2 Product Documentation
xdmp:directory-createxdmp:directory-create(
$uri as xs:string,
[$permissions as element(sec:permission)*],
[$collections as xs:string*],
[$quality as xs:int?],
[$forest-ids as xs:unsignedLong*],
[$options as (element()|map:map)?]
) as empty-sequence()
Summary
Creates a directory. If security is enabled,
the document permissions and collections are set to the given parameters,
if supplied. Otherwise, the current user's default permissions and/or
collections are applied. If the beginning of the document URI is
protected, the user must have access to that URI privilege. If the
directory URI does not end with a '/' one is added. If the directory already
exists, then an XDMP-DIREXISTS exception is thrown.
Parameters |
uri |
The URI of the directory to be inserted.
|
$permissions |
Security permission elements corresponding to the permissions
for the document.
|
collections |
The collections to which the new directory belongs.
|
quality |
The quality of this document. A positive value increases
the relevance score of the document in text search functions.
The converse is true for a negative value. The default value is 0.
|
forest-ids |
Specifies the ID of the forest in which this directory is created.
If the directory already exists in the database and if $forest-ids is
not specified, it will remain in its existing forest. If no such
forest exists or if no such forest is attached to the context database,
an error is raised. If multiple forests are specified, the directory
is created in one of the specified forests.
If you have local disk failover enabled, specify the ID of the master
forest. In the event of a failover, MarkLogic server will automatically
redirect documents to the replica forest. Specify the ID of the replica
forest will result in a "forest not in database" error.
|
options |
Options with which to customize this operation. You
can specify options as either an options XML element
in the "xdmp:directory-create" namespace, or as a map:map .
The options names below are XML element localnames. When using a map,
replace the hyphens with camel casing. For example, "an-option"
becomes "anOption" when used as a map:map key.
- if-exists
- Action if directory already exists with the URI. Valid values are "error"
and "allow". Default value is "error". An XDMP-DIREXISTS exception is
thrown if the directory exists when "error" is specified or this
option is left unspecified.
|
Example
xdmp:directory-create("http://marklogic.com/a/",
(xdmp:permission("development", "update"),
xdmp:permission("qa", "read")),
"http://marklogic.com/directories")
=> Creates a directory named "http://marklogic.com/a/",
which has the parent directory "http://marklogic.com/".
The directory is created with the specified permissions,
and is added to the "http://marklogic.com/directories"
collection.
Example
xdmp:directory-create("/dir/myDirectory/")
=> Creates a directory named "/dir/myDirectory/",
which has the parent directory "/dir/", which
in turn has parent directory "/". If
directory creation is set to automatic in
the database configuration, this example creates
all three directories ("/", "/dir/", and
"/dir/myDirectory/").
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.