The table below lists all the
op built-in
functions (in this namespace:
).
You can also view these functions broken down by category:
The optic library module is a fluent API that builds up a plan definition
for retrieving and processing rows. The result
method executes the plan.
The plan operations fall into the following broad categories:
where
method,
sort rows with
orderBy
, group rows with groupBy
, project rows with
select
, or page over rows with limit
.joinLeftOuter
, union
, intersect
,
or except
methods to yield a single row set.To use this module in your Server-Side JavaScript code, include a
require
statement similar to following line in your code:
var op = require("/MarkLogic/optic");
The optic JavaScript module is installed as the following file:
install_dir/Modules/MarkLogic/optic.sjs
where install_dir
is the directory in which
MarkLogic Server is installed.
Function name | Description |
---|---|
op.add | This function returns the sum of the specified numeric expressions. |
op.and | This function returns true if the specified boolean expressions all return true. |
op.arrayAggregate | This function constructs an array whose items are the result of evaluating the column for each row in the group or row set. |
op.as | This function defines a column by assigning the value of an expression over the rows in the row set. |
op.asc | This function sorts the specified columndef in ascending order. |
op.avg | This function averages the non-null values of the column for the rows in the group or row set. |
op.call | This function calls value processing built-in functions that aren't listed in the list Value Processing Functions, the API also provides a general-purpose constructor for deferred calls. |
op.case | This function returns the specified valueExpression if the specified valueExpression is true. |
op.col | Identifies a column where the column name is unique and a qualifier on the column name isn't necessary (and might not exist). |
op.count | This function counts the rows where the specified input column has a value. |
op.desc | This function sorts the specified columndef in descending order. |
op.divide | This function divides the left numericExpression by the right numericExpression and returns the value. |
op.eq | This function returns true if the left and right expressions return the same value. |
op.fragmentIdCol | Specifies a name for adding a fragment id column to the row set identifying the source documents for the rows from a view, lexicons or triples. |
op.fromLexicons | This function dynamically constructs a view from range indexes or the uri or collection lexicons. |
op.fromLiterals | Constructs a literal row set as in the SQL VALUES or SPARQL VALUES statements. |
op.fromSPARQL | This function dynamically constructs a row set based on a SPARQL SELECT query from triples. |
op.fromSQL | This function dynamically constructs a row set based on a SQL SELECT query from views. |
op.fromTriples | Reads rows by matching patterns in the triple index. |
op.fromView | This function reads a row set from a configured view over TDE-indexed rows or a predefined view over range indexes. |
op.ge | This function returns true if the value of the left expression is greater than or equal to the value of the right expression. |
op.graphCol | Identifies the graph for a triple providing one or more columns for a row. |
op.groupConcat | This function concatenates the non-null values of the column for the rows in the group or row set. |
op.gt | This function returns true if the value of the left expression is greater than the value of the right expression. |
op.import | This function instantiates a plan from the JSON representation of a plan that was exported by the prototype.export function. |
op.isDefined | This function tests whether the value of an expression is null in the row where the expression might be as simple as a column identified by op.col . |
op.jsonArray | This function constructs a JSON array during row processing. |
op.jsonBoolean | This function constructs a JSON boolean node with the specified value. |
op.jsonDocument | This function constructs a JSON document with the root content, which must be exactly one JSON object or array node. |
op.jsonNull | This function constructs a JSON null node. |
op.jsonNumber | This function constructs a JSON number node with the specified value. |
op.jsonObject | This function constructs a JSON object with the specified properties. |
op.jsonString | This function constructs a JSON text node with the specified value. |
op.le | This function returns true if the value of the left expression is less than or equal to the value of the right expression. |
op.lt | This function returns true if the value of the left expression is less than the value of the right expression. |
op.max | This function gets the largest non-null value of the column for the rows in the group or row set. |
op.min | This function gets the smallest non-null value of the column for the rows in the group or row set. |
op.modulo | This function returns the remainder afer the division of the dividend and divisor expressions. |
op.multiply | This function multiplies the left numericExpression by the right numericExpression and returns the value. |
op.ne | This function returns true if the value of the left expression is not equal to the value of the right expression. |
op.not | This function returns true if neither of the specified boolean expressions return true. |
op.on | Specifies an equijoin using one columndef each from the left and right rows. |
op.or | This function returns true if either of the specified boolean expressions return true. |
op.param | This function creates a placeholder for a literal value in an expression or as the offset or max for a limit. |
op.pattern | This function builds the parameters for the op.fromTriples function. |
op.prefixer | This function factory returns a new function that takes a name parameter and prepends the specified base URI onto the name. |
op.prop | This function specifies the key expression and value content for a JSON property of a JSON object contructed by the op.jsonObject function. |
op.sample | This function randomly selects one non-null value of the column from the rows in the group or row set. |
op.schemaCol | Unambiguously identifies a column with the schema name, view name, and column name. |
op.sequenceAggregate | This call constructs a sequence whose items are the values of a column for each row in the group or row set. |
op.sqlCondition | This function returns a filter definition as input for a WHERE operation. |
op.subtract | This function subtracts the right numericExpression from the left numericExpression and returns the value. |
op.sum | This function adds the non-null values of the column for the rows in the group or row set. |
op.toSource | This function generates a server-side JavaScript source code representation of a plan from the JSON or JavaScript literal object representation of a plan that was exported by the prototype.export function. |
op.uda | This function processes the values of column for each row in the group or row set with the specified user-defined aggregate as implemented by an aggregate user-defined function (UDF) plugin. |
op.viewCol | Identifies a column where the combination of view and column name is unique. |
op.when | This function executes the specified expression if the specified condition is true for the row. |
op.xmlAttribute | This function constructs an XML attribute with the name (which can be a string or QName) and atomic value. |
op.xmlComment | This function constructs an XML comment with the atomic value. |
op.xmlDocument | This function constructs an XML document with the root content, which must be exactly one node. |
op.xmlElement | This function constructs an XML element with the name (which can be a string or QName), zero or more attributes, and child content. |
op.xmlPI | This function constructs an XML processing instruction with the atomic value. |
op.xmlText | This function constructs an XML text node with the specified value. |
op.xpath | This function extracts a sequence of child nodes from a column with node values -- especially, the document nodes from a document join. |