Loading TOC...

sem.databaseNodes

sem.databaseNodes(
   $triples as sem.triple[],
   [$options as String[]],
   [$query as cts.query?]
) as Sequence

Summary

This function returns database nodes backing given triples. Any given cts:triple may be backed by zero, one, or multiple database nodes.

Parameters
$triples The triples to locate.
$options Matching options. Valid options include:
=
Specify equality matching (following the rules of the $operator argument to cts:triples).
sameTerm
Specify sameTerm matching (following the rules of the $operator argument to cts:triples) (if neither '=' nor 'sameTerm' are specified, this option gets used by default).
all
Specify to return all triple-backing nodes, no matter where or in what format they occur in MarkLogic 7, only sem:triple elements are recognized as triples). If this option is not specified, only sem:triple elements found in documents that have the root element of sem:triples will be returned.
quads
Specify to examine the graph component in the passed in sem:triples and use it to match.
$query A cts:query to limit the scope of nodes returned.

Example

// Find the URIs of all documents containing a specified triple
const sem = require('/MarkLogic/semantics');

const triple = sem.triple(
  sem.iri('http://dbpedia.org/resource/Judith_Massare'), 
  sem.iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), 
  sem.iri('http://xmlns.com/foaf/0.1/Person'));

var results = [];
for (const node of sem.databaseNodes(triple)) {
  results.push(xdmp.nodeUri(node));
}
results

// Returns, for example:
//   ['/my/unmanaged-triples.xml']

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

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.