Loading TOC...


   $plan as map:map,
   [$outType as xs:string?],
   [$bindings as map:map],
   [$options as xs:sring*]
) as xs:string?


This method executes the plan (mapping or reducing, if specified) to generate the result, which is a sequence of map:map or json:array rows, unless mapped or reduced to different output.

$plan The Optic Plan. You can either use the XQuery => chaining operator or specify the variable that captures the return value from the previous operation.
$outType This parameter specifies the outputType as either "object" (the default) for a map:map sequence with keys of the column names and values of the column values or "array" for a json:array with the list of column names as an initial header and the column values in the same order for the subsequent rows.
$bindings This parameter provides a map with the names and values of placeholder parameters. An error is thrown if a placeholder parameter is not bound.
$options Options as an array of string values. Available options are:
  • "trace=ID"

    This parameter outputs the query's plan, optimization and execution details in the log while getting results. ID is the identifier to identify the query in the logs.

  • "optimize=N"

    Sets the optimization level to use. Levels of 0 (off), 1, and 2 are recognized. The default is 1.

  • "seed=N"

    Sets the seed to use. The default will generate a random seed. Setting it to 0 will behave the same as the default case. The default is 0.

See Also


xquery version "1.0-ml";

import module namespace op="http://marklogic.com/optic"
     at "/MarkLogic/optic.xqy";

op:from-view("main", "employees")
   => op:select(("EmployeeID", "FirstName", "LastName"))
   => op:order-by("EmployeeID")
   => op:result((), (), ("trace=myQuery", "optimize=1"))

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