Loading TOC...

MarkLogic 10 Product Documentation
op functions

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:

  • data access -- a plan can read a row set from a view, graph, lexicons, or literals.
  • row set modification -- a plan can filter rows with the where method, sort rows with orderBy, group rows with groupBy, project rows with select, or page over rows with limit.
  • row set composition -- a plan can combine multiple row sets with the joinInner, joinLeftOuter, joinFullOuter, union, intersect, or except methods to yield a single row set.
  • row result processing -- a plan perform document joins and apply map or reduce functions to the final row set.

To use this module in your Server-Side JavaScript code, include a require statement similar to following line in your code:

                   const 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.

74 functions
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 rows by the values of the specified column 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.bucketGroup This function can be used as a named group in functions prototype.groupToArrays or prototype.facetBy .
op.call This function to calls a built-in function on every row.
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.columnInfo This function can be used to inspect the state of a plan before execution.
op.count This function counts the rows where the specified input column has a value.
op.cube This function specifies a list of grouping keys for a group and returns that group and every possible larger group (including all rows) formed from any subset of keys.
op.desc This function sorts the rows by the values of the specified column in descending order.
op.divide This function divides the left numericExpression by the right numericExpression and returns the value.
op.eq This function takes two or more expressions and returns true if all of the 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.fromSearch This function dynamically constructs a row set based on a cts.query where the columns for the document fragment id and score reflecting the degree of match of the document with the query criteria.
op.fromSearchDocs This function matches and returns the uri, content, and score for documents.
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.group This function specifies the grouping keys for a group as a list of zero or more columns.
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.hasGroupKey This aggregate function adds a flag to a grouped row specifying whether a column acted as a grouping key for the row.
op.import This function instantiates a plan from the JSON representation of a plan that was exported by the prototype.export function.
op.in This function returns true if a test expression evaluates to the same value as any of a list of candidate expressions.
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.namedGroup This function specifies the grouping keys for a group as a named list of zero or more columns.
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 constructed by the op.jsonObject function.
op.rollup This function specifies a list of grouping keys for a group and returns that group and larger groups (including all rows) formed by dropping columns from right to left.
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.