Loading TOC...

MarkLogic 12 EA 2 Product Documentation
op:join-doc-cols

op:join-doc-cols(
   $cols as map:map,
   $sourceCol as item()
) as map:map

Summary

This function populates the view with the uri, doc, collections, metadata, permissions, and / or quality document descriptor columns for database document values.

Parameters
$cols Supplies a document column identifier map to specify which document columns to join and their names. The names cannot conflict with existing column names. To use the default column names, use op:doc-cols or an empty sequence.
$sourceCol The source column to join. This is either an op:fragment-id-col specifying a fragment id column or a op:col, op:view-col or op:schema-col that contains document uris. Joining on a fragment id is more efficient than joining on an uri column.

Example

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

let $docColIdentifier := map:map()=>map:with("uri", "newUri")
                        =>map:with("doc", "doc")
                        =>map:with("collections", "collections")
                        =>map:with("metadata", "metadata")
                        =>map:with("permissions", "permissions")
                        =>map:with("quality", "quality")
                        =>map:with("temporalCollection", "temporalCollection")
return op:from-doc-uris(cts:word-query('duck', ('case-sensitive')))
  =>op:join-doc-cols($docColIdentifier, op:fragment-id-col("fragmentId"))
  =>op:order-by("newUri")
  =>op:result()
  

Example

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

let $docColIdentifier := map:map()=>map:with("doc", "doc")
return op:from-doc-uris(cts:word-query('duck', ('case-sensitive')))
  =>op:join-doc-cols($docColIdentifier, op:col("uri"))
  =>op:order-by("uri")
  =>op:result()
  

Example

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

op:from-doc-uris(cts:word-query('duck', ('case-sensitive')), "A")
  =>op:join-doc-cols(op:doc-cols("A", ("uri", "doc", "collections")), op:view-col("A", "uri"))
  =>op:order-by(op:view-col("A", "uri"))
  =>op:result()
  

Example

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

op:from-doc-uris(cts:word-query('duck', ('case-sensitive')))
  =>op:join-doc-cols((), op:fragment-id-col("fragmentId"))
  =>op:order-by("uri")
  =>op:result()
  

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