Loading TOC...

op.fromLexicons

op.fromLexicons(
   $indexdef as String,
   [$qualifier as String],
   [$systemCols as String]
) as AccessPlan

Summary

This function dynamically constructs a view from range indexes or the uri or collection lexicons. This function will only return rows for documents where the first column has a value. The keys in the map specify the names of the columns and the values in the map provide cts.reference objects to specify the lexicon providing the values of the columns. Optic emits rows based on co-occurrence of lexicon values within the same document similar to cts.valueTuples If the cts.reference sets the nullable option to true, the column is optional in the row.

This function creates a row set without a limit. Use AccessPlan.prototype.limit or AccessPlan.prototype.offsetLimit to set a limit.

Parameters
$indexdef An object in which each key is a column name and each value specifies a cts.reference for a range index or other lexicon (especially the cts.uriReference lexicon) with the column values.
$qualifier Specifies a name for qualifying the column names. By default, lexicon rows have no qualification. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names.
$systemCols An optional named fragment id column returned by the op.fragmentIdCol function. The fragment id column can be used for joins.

Usage Notes

The fromLexicons function is one of the Data Access Functions.

Example


// Return the EmployeeID, FirstName, LastName, the URI of the document 
// holding the data, and document fragment ID for each employee with 
// 'Manager' in their Position title.

const op = require('/MarkLogic/optic');

const Plan =
op.fromLexicons({
            EmployeeID: cts.elementReference(xs.QName('EmployeeID')),
            FirstName: cts.elementReference(xs.QName('FirstName')),
            LastName: cts.elementReference(xs.QName('LastName')),
            URI: cts.uriReference()}, 
            null, 
            op.fragmentIdCol('Document Fragment'));

Plan.result();
  

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