Loading TOC...
Matches for cat:function (cat:function (cat:function/xquery)) have been highlighted. remove

MarkLogic Server 11.0 Product Documentation
flexrep:target-create

flexrep:target-create(
   $cfg as element(flexrep:configuration),
   $name as xs:string,
   $urls as xs:string*,
   $retry-seconds-min as xs:unsignedInt?,
   $retry-seconds-max as xs:unsignedInt?,
   $documents-per-batch as xs:unsignedInt?,
   $enabled as xs:boolean?,
   $http-options as element(flexrep:http-options)?,
   $replicate-cpf as xs:boolean?,
   $filter-module as xs:string?,
   $filter-options as element(flexrep:filter-options)?,
   [$user-id as xs:unsignedLong?],
   [$immediate-push as xs:boolean]
) as element(flexrep:configuration)

Summary

This function creates a new target and add it to the specified configuration. A random ID is chosen for the target. You must subsequently use flexrep:configuration-insert to write the modified configuration into the database.

Parameters
cfg The configuration to which to add the target.
name The name of the target.
urls The URLs to be used to push replicated content to, with the load spread across them if there is more than one. If none are specified, the target is expected to do a pull.
retry-seconds-min The minimum time to wait before scheduling a push retry.
retry-seconds-max The maximum time to wait before scheduling a push retry.
documents-per-batch The number of documents to attempt to replicate from a single invocation of the scheduled replication task.
enabled Specifies whether or not this target is enabled.
http-options HTTP options to use when connecting to the target. Specify the options as an XML element named http-options in the "flexrep" namespace. The options element can contain any of the options from the xdmp:http-get function. When including an option from another function, use use the namespace appropriate to that function in the option child element. For more details, see the Examples.
replicate-cpf Determines whether to replicate CPF. Set to true to replicate CPF. Otherwise set to false. In most circumstances, you will not want to replicate CPF.
filter-module A main module to filter replication attempts.
filter-options Options to apply when invoking an outbound filter module. Specify the options as an XML element named filter-options in the "flexrep" namespace. The options element can contain any of the options from xdmp:invoke. The option child elements from xdmp:invoke must be in the "xdmp:eval" namespace.
user-id The user ID if this is a query-based target.
immediate-push Specifies whether to push to the query-based target immediately. The default is true.

Example

  xquery version "1.0-ml"; 

  import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication" 
      at "/MarkLogic/flexrep.xqy";

  (: Obtain the ID of the replicated CPF domain from the Triggers database. :)
  let $domain:= xdmp:eval(
    'xquery version "1.0-ml";
    import module namespace dom = "http://marklogic.com/cpf/domains" 
      at "/MarkLogic/cpf/domains.xqy";
    fn:data(dom:get( "Replicated Content" )//dom:domain-id)',
    (),
    <options xmlns="xdmp:eval">
      <database>{xdmp:database("MyTriggers")}</database>
    </options>)

  (: Obtain the replication configuration. :)
  let $cfg := flexrep:configuration-get($domain, fn:true()) 

  (: Specify the HTTP options for the replication target. :)
  let $http-options := 
    <flexrep:http-options
      xmlns:flexrep="http://marklogic.com/xdmp/flexible-replication">
      <http:authentication xmlns:http="xdmp:http">
        <http:username>admin</http:username>
        <http:password>admin</http:password>
      </http:authentication>
      <http:client-cert xmlns:http="xdmp:http"/>
      <http:client-key xmlns:http="xdmp:http"/>
      <http:pass-phrase xmlns:http="xdmp:http"/>
    </flexrep:http-options>

  (: Create the replication target. :)
  let $cfg := flexrep:target-create(
    $cfg,
    "Replica",
    "http://localhost:8011/",
    60,
    300,
    10,
    fn:true(),
    $http-options,
    fn:false(),
    (),
    () ) 

  (: Insert the changes to the replication configuration. :)
  return flexrep:configuration-insert($cfg) 
 
  (: Creates a replication target, named "Replica." :)   
    

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