op:export( $plan as map:map ) as map:map
This method generates a serialized representation of the Optic query to JSON so that it can be persisted as a file or used as a REST payload. Only the Optic query can be exported, not the results of executing an Optic query. A mapper or reducer function cannot be exported if it is an anonymous function. The export for a named function identifies the module path and function name.
For more information, see Exporting and Importing a Serialized Optic Query in the Application Developer's Guide
Parameters | |
---|---|
$plan | The Optic Plan to be exported. |
xquery version "1.0-ml"; import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy"; let $plan := op:from-view("main", "employees") => op:select(("EmployeeID", "FirstName", "LastName")) => op:order-by("EmployeeID") => op:export() return xdmp:document-insert("plan.json", xdmp:to-json($plan))