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:

To use the optic.xqy module in your own XQuery modules, include the following line in your XQuery prolog:

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

The library uses the op: namespace, which is not predefined in the server.

131 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 expressions all return true.
op:array-aggregate 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:bind This function adds new columns or modifies existing columns based on expressions while preserving existing unmodified columns in the row set.
op:bind-as This function is deprecated in favor of the bind() function and will not be supported in MarkLogic 11.
op:bucket-group This function can be used as a named group in functions op:group-to-arrays or op:facet-by.
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:column-info 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:doc-col-types Provides the 3rd parameter for op:from-param for row column types.
op:doc-cols Constructs a document column identifier object for columns of uri, doc, collections, metadata, permissions, quality and temporalCollection.
op:eq This function takes two or more expressions and returns true if all of the expressions return the same value.
op:except This method restricts the left row set to rows where a row with the same columns and values doesn't exist in the right row set.
op:execute This method executes the plan.
op:exists-join This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
op:explain This method returns a representation of the builtin execution plan.
op:export 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.
op:facet-by This method counts values for multiple grouping key columns.
op:fragment-id-col 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:from-doc-descriptors This function constructs document rows from the docsDescriptors.
op:from-doc-uris This function matches and returns the uri, content, and score for documents.
op:from-lexicons This function dynamically constructs a view from range indexes or the uri or collection lexicons.
op:from-literals Constructs a literal row set as in the SQL VALUES or SPARQL VALUES statements.
op:from-param This function constructs document rows with rows provided by a parameter.
op:from-search 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:from-search-docs This function matches and returns the uri, content, and score for documents.
op:from-sparql This function dynamically constructs a row set based on a SPARQL SELECT query from triples.
op:from-sql This function dynamically constructs a row set based on a SQL SELECT query from views.
op:from-triples Reads rows by matching patterns in the triple index.
op:from-view 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:generate-view This method generates a view that encapsulates a query.
op:graph-col 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:group-by This method collapses a group of rows into a single row.
op:group-by-union This method performs the union of multiple group-by operations on a row set.
op:group-concat This function concatenates the non-null values of the column for the rows in the group or row set.
op:group-to-arrays This method performs multiple group-by operations on a row set and produces a single row with a column for each group having an array value whose items are the rows for the group.
op:gt This function returns true if the value of the left expression is greater than the value of the right expression.
op:has-group-key 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 op: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:insert-after Insert a new node after another node.
op:insert-before Insert a new node before another node.
op:insert-child Insert a node as child.
op:insert-named-child This method is specific for JSON and inserts a key/value pair to an object.
op:intersect This method restricts the left row set to rows where a row with the same columns and values exists in the right row set.
op:is-defined 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:join-cross-product This method yields one output row set that concatenates every left row with every right row.
op:join-doc This function specifies a document column to add to the rows by reading the documents for an existing source column having a value of a document uri (which can be used to read other documents) or a fragment id (which can be used to read the source documents for rows).
op:join-doc-and-uri This method adds an uri column and a document column to rows based on an existing source column having a value of a document uri (which can be used to read other documents) or a fragment id (which can be used to read the source documents for rows).
op:join-doc-cols This function populates the view with the uri, doc, collections, metadata, permissions, and / or quality document descriptor columns for database document values.
op:join-doc-uri This method adds a uri column to rows based on an existing fragment id column to identify the source document for each row.
op:join-full-outer This method yields one output row set with the rows from an inner join as well as the other rows from both the left and right row sets.
op:join-inner This method returns all rows from multiple tables where the join condition is met.
op:join-left-outer This method yields one output row set with the rows from an inner join as well as the other rows from the left row set.
op:json-array This function constructs a JSON array during row processing.
op:json-boolean This function constructs a JSON boolean node with the specified value.
op:json-document This function constructs a JSON document with the root content, which must be exactly one JSON object or array node.
op:json-null This function constructs a JSON null node.
op:json-number This function constructs a JSON number node with the specified value.
op:json-object This function constructs a JSON object with the specified properties.
op:json-string 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:limit This method specifies the maximum number of rows to be returned by this Plan.
op:lock-for-update Gets an early lock on documents that will be updated later in the pipeline with an operation like remove() or write().
op:lt This function returns true if the value of the left expression is less than the value of the right expression.
op:map This method applies the specified function to each row returned by the plan to produce a different result row.
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:named-group 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:not-exists-join This method is a filtering join that filters based on whether the join exists or not but doesn't add any columns.
op:offset This method returns a subset of the rows in the result set.
op:offset-limit This method returns a subset of the rows in the result set by skipping the number of rows specified by start and returning the remaining rows up to the length limit.
op:on Specifies an equijoin using one columndef each from the left and right rows.
op:on-error Add an error-handler to the Optic Pipeline to catch Optic Update runtime errors.
op:or This function returns true if the specified expressions all return true.
op:order-by This method sorts the row set by the specified order definition.
op:param This function creates a placeholder for a literal value in an expression or as the offset or max for a limit.
op:patch Builds a patch operation including a sequence of inserts, replaces, replace-inserts and deletes.
op:patch-builder Create a patch builder which can be used to chain patch operations.
op:pattern This function builds the parameters for the op:from-triples function.
op:prefixer This function factory returns a new function that takes a name parameter and returns a sem:iri, prepending the specified base URI onto the name.
op:prepare This method prepares the specified plan for execution as an optional final step before execution.
op:prop This function specifies the key expression and value content for a JSON property of a JSON object constructed by the op:json-object function.
op:reduce This method applies a function or the builtin reducer to each row returned by the plan to produce a single result as with the reduce() method of JavaScript Array.
op:remove This method deletes a document from the database.
op:replace Replace a node with another node.
op:replace-insert-child Replace a child if it exist, or insert if it does not exist.
op:replace-value Replace the value of a path with a new value.
op:result 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.
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:sample-by This function samples rows from a view or from a pattern match on the triple index.
op:schema-col Unambiguously identifies a column with the schema name, view name, and column name.
op:select This call projects the specified columns from the current row set and / or applies a qualifier to the columns in the row set.
op:sequence-aggregate This call constructs a sequence whose items are the values of a column for each row in the group or row set.
op:sql-condition 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:to-source This function generates an XQuery source code representation of a plan from the JSON or JavaScript literal object representation of a plan that was exported by the op:export function.
op:transform-doc This function applies a transformation to a column that contains documents.
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:union This method yields all of the rows from the input row sets.
op:unnest-inner This function flattens an array value into multiple rows.Then performs a op:join-inner on the rest of the rows.
op:unnest-left-outer This function flattens an array value into multiple rows.Then performs a op:join-left-outer on the rest of the rows.
op:validate-doc Validate the document based on a supplied schema.
op:view-col 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:where This method restricts the row set to rows matched by the boolean expression.
op:where-distinct This method removes duplicate rows from the row set.
op:write Inserts or overwrites the documents identified by the uri column with the data supplied by the other document descriptor columns.
op:xml-attribute This function constructs an XML attribute with the name (which can be a string or QName) and atomic value.
op:xml-comment This function constructs an XML comment with the atomic value.
op:xml-document This function constructs an XML document with the root content, which must be exactly one node.
op:xml-element This function constructs an XML element with the name (which can be a string or QName), zero or more attributes, and child content.
op:xml-pi This function constructs an XML processing instruction with the atomic value.
op:xml-text 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.
Powered by MarkLogic Server | Terms of Use | Privacy Policy