Loading TOC...

op:join-doc-and-uri

op:join-doc-and-uri(
   $plan as map:map,
   $docCol as item(),
   $uriCol as item(),
   $sourceCol as item()
) as map:map

Summary

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). If the fragment id column is null in the row, the row is dropped from the rowset.

You should minimize the number of documents retrieved by filtering or limiting rows before joining documents.

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.
$docCol The document column to add to the rows. This can be a string or a column, op:col, op:view-col or op:schema-col, specifying the name of the new column that should have the document as its value.
$uriCol The uri column to add to the rows. This can be a string or a column, op:col, op:view-col or op:schema-col, specifying the name of the new column that should have the document uri as its value.
$sourceCol The document uri or fragment id value. This is either an op:fragment-id-col specifying a fragment id column or a document uri column as xs:string or as a column using op:col, op:view-col or op:schema-col. Joining on a fragment id is more efficient than joining on a uri column.

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
at "/MarkLogic/optic.xqy";

op:from-search(cts:document-format-query('json'),('fragmentId'))
  => op:join-doc-and-uri('doc', 'uri', op:fragment-id-col('fragmentId'))
  => op:result()
  

Example

xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
at "/MarkLogic/optic.xqy";

op:from-search(cts:document-format-query('json'),('fragmentId'))
  => op:join-doc-and-uri('doc', 'newUri', op:col('uri'))
  => op:result()
  

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