Loading TOC...


   filterExpression as filterDefinition
) as ModifyPlan


This method restricts the row set to rows matched by the boolean expression. Use boolean composers such as op.and and op.or to combine multiple expressions.

A constraining document query returns only the rows from the matched source documents. If the constraining document query is a node instead of a cts.query object, the implementation calls the cts.query parser on the node. The constraining document query applies to all upstream accessors. A constraining sem.store returns only the triples from the specified store (potentially expanded by inference using a ruleset). A constraining sem.store applies to all upstream triples accessors.

filterExpression This can be a boolean expression, a cts.query to qualify the source documents that produced the rows set, or (where part of the row set was produced by the op.fromTriples accessor) a sem.store to restrict or expand the triples that produce the row set.

Usage Notes

where is a method of the following classes:


// Locate employee expenses that exceed the allowed limit

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

const employees = op.fromView('main', 'employees');
const expenses = op.fromView('main', 'expenses');
const expenselimit = op.fromView('main', 'expenselimit');

const Plan =
employees.joinInner(expenses, op.on(employees.col('EmployeeID'), expenses.col('EmployeeID')))
         .joinInner(expenselimit, op.on(expenses.col('Category'), expenselimit.col('Category')))
         .where(op.gt(expenses.col('Amount'), expenselimit.col('Limit') ))
         .select([employees.col('EmployeeID'), 'FirstName', 'LastName', expenses.col('Category'),
                  expenses.col('Amount'),  expenselimit.col('Limit') ])



// Insert the template for view "docWhereExample"
const tde = require("/MarkLogic/tde.xqy");
const template = {
    "collections": ["docWhereExample"],
tde.templateInsert("docWhereTemplate.json", template);

//Insert documents
const docs = [{
   uri: "john.json",
   id : 1,
   name: "john",
   sentence : "John is there"
   uri: "joe.json",
   id : 1,
   name: 'joe',
   sentence : "Joe was there"
   uri: "alice.json",
   id : 2,
   name: 'alice',
   sentence : "Alice was there"
for ( let doc of docs ) {
xdmp.documentInsert(doc.uri, doc, {collections:"docWhereExample"})

//Below query returns "joe"
const op = require('/MarkLogic/optic');
op.fromView('docWhereExample', 'docWhereExample')

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