dls:retention-rule( $name as xs:string, $comment as item()*, $num-versions as xs:unsignedInt?, $duration as xs:duration?, $document-query-text as xs:string?, $document-query as cts:query? ) as element(dls:retention-rule)
This function creates and returns a retention rule element.
Use
dls:insert-retention-rule
to insert the retention rule into
the database.
$num-versions
and $duration
retains a numbered
version only if it is both one of the N most recent versions and it was
created more recently than "now - duration." If neither
$num-versions
or $duration
is specified,
then any numbered version matching the document query is kept forever.
The $document-query-text
parameter is intended to be
used for the human readable form of a query that was used to produce the
corresponding
cts:query
. This may be the text that a user
typed into a search text field in the UI. This parameter does NOT affect
the retention policy.
dls-admin
role is required to run
this function, or the privilege:http://marklogic.com/xdmp/privileges/dls-admin
xquery version "1.0-ml"; import module namespace dls="http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy"; dls:retention-rule( "All Versions Retention Rule", "Retain all versions of all documents", (), (), "Locate all of the documents", cts:and-query(())) (: Returns a retention rule in XML format. :)
xquery version "1.0-ml"; import module namespace dls = "http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy"; dls:retention-rule( "Rule1", "Keep the five most recent versions of Jim's documents that are 15 days old or newer", 5, xs:duration("P15D"), "Locate documents authored by Jim", dls:author-query(xdmp:user("Jim"))) (: Returns a retention rule in XML format. :)
xquery version "1.0-ml"; import module namespace dls = "http://marklogic.com/xdmp/dls" at "/MarkLogic/dls.xqy"; dls:retention-rule( "Rule2", "Keep the five most recent versions of Jim's documents in the 'foo' collection that are 15 days old or newer", 5, xs:duration("P15D"), "Locate documents in the 'foo' collection authored by Jim", cts:and-query(( cts:collection-query("http://marklogic.com/documents/foo"), dls:author-query(xdmp:user("Jim")) )) ) (: Returns a retention rule in XML format. :)
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.