Loading TOC...

xdmp:document-set-collections

xdmp:document-set-collections(
   $uri as xs:string,
   $collections as xs:string*
) as empty-sequence()

Summary

Sets the named document to belong to the given collections, replacing any previously set collections on the named document. To preserve existing collections, use xdmp:document-add-collections. For each collection that is protected, the user must have permissions to update that collection or have the any-collection privilege. For each unprotected collection, the user must have the unprotected-collections privilege.

Parameters
$uri The document URI.
$collections A set of collection URIs.

Example

xdmp:document-set-collections(
  "/example.xml",
  ("http://examples.com", "http://marklogic.com"))

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • Is it possible create a collections inside other collection? for example I have a collection COMPANY and from this collection I want to create a few collections (CLIENT, PROVIDER, etc), so that I could search documents for a client by filtering for its collections as PROFILE, PROVIDER, etc. I don't want insert a document in different collections, just one document per collections. In this example I have 2 collections COMPANY1 and COMPANY2, for every collection I want to have a few collections(CLIENT, PROVIDER) as we can see: COLLECTION1 --> COLLECTION2 --> DOC-URI ------------------------------------------------------------------ COMPANY1 --> CLIENT --> /code/client/client1_company1.xml COMPANY1 --> CLIENT --> /code/client/client2_company1.xml COMPANY1 --> PROVIDER --> /code/provider/provider1_company1.xml COMPANY1 --> PROVIDER --> /code/provider/provider2_company1.xml COMPANY2 --> CLIENT --> /code/client/client1_company2.xml COMPANY2 --> CLIENT --> /code/client/client2_company2.xml COMPANY2 --> PROVIDER --> /code/provider/provider1_company2.xml COMPANY2 --> PROVIDER --> /code/provider/provider2_company2.xml
    • Collections can't be inside of other collections, but you can assign multiple collections and look for the intersection of them. In other words, you could assign a document to collections "company1" and "client", then your query could be "cts:and-query((cts:collection-query("company1"), cts:collection-query("client"))". If you really want the hierarchy, I would use directories for that.