Loading TOC...

MarkLogic 12 EA 1 Product Documentation
xdmp.setServerField

xdmp.setServerField(
   name as String,
   value as Sequence
) as Sequence

Summary

Sets the value of a named server field. A server field is created with xdmp.setServerField and stores a name/value pair in memory. The server field is available on the App Server in which it is set on the host in which the App Server runs, via xdmp.getServerField; a server field that is set on one App Server is not available on other App Servers on that host or on the same App Server running on another host.

Parameters
name The name of the server field.
value The value of the server field. If you pass in a single value, it is treated as a Sequence with that single item; therefore, if you pass in an array, the array is treated as a single value (not as one value for each item in the array). If you mean to pass in the values of each item in the array, then you can call xdmp.arrayValues on the array.

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-set-server-field

Usage Notes

If you use a server field with the system Plugin Framework (by placing the xdmp.setServerField code in a main module under the Plugins directory on a host), then the server field will be populated for each App Server on the host before the first request against each App Server is run.

If you set a server field to the empty sequence, it deletes the server field and it will not appear when you run xdmp.getServerFieldNames.

If you set a session or server field to a value that comes from a database node (for example, from the value of a search or the fn.doc function), then that session or server field expires after the request time limit (10 minutes by default). These fields expire because they contain references to stands in the database, and as long as those references exist the stand cannot be reclaimed (merged). To keep such a node in a session or server field, make a copy of the node before adding it to the session or server field instead of using the node directly from the database.

Example

xdmp.setServerField("foo", "bar");
=> "bar"

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