op:where( $plan as map:map, $condition as item() ) as map:map
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.
Parameters | |
---|---|
$plan | The Optic Plan. You can either use the XQuery => chaining operator or specify the variable that captures the return value from the previous operation. |
$condition | 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:from-triples accessor) a sem:store to restrict or expand the triples that produce the row set. |
xquery version "1.0-ml"; import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy"; let $employees := op:from-view("main", "employees") let $expenses := op:from-view("main", "expenses") let $expenselimit := op:from-view("main", "expenselimit") return $employees => op:join-inner($expenses, op:on( op:view-col("employees", "EmployeeID"), op:view-col("expenses", "EmployeeID"))) => op:join-inner($expenselimit, op:on( op:view-col("expenses", "Category"), op:view-col("expenselimit", "Category"))) => op:where(op:gt(op:view-col("expenses", "Amount"), op:view-col("expenselimit", "Limit"))) => op:select((op:view-col("employees", "EmployeeID"), "FirstName", "LastName", op:view-col("expenses", "Category"), op:view-col("expenses", "Amount"), op:view-col("expenselimit", "Limit"))) => op:order-by(op:view-col("employees", "EmployeeID")) => op:result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.