Loading TOC...

op.fromTriples

op.fromTriples(
   $patterndef as String,
   [$qualifier as String],
   [$graphIri as String],
   [$tripleOptions as String]
) as AccessPlan

Summary

Reads rows by matching patterns in the triple index.

The rows have a column for each column name in the patterns. While each column will have a consistent datatype for all rows from a view, the columns of rows from a graph may have varying data types, which could affect joins.

This function creates a row set without a limit. Use AccessPlan.prototype.limit or AccessPlan.prototype.offsetLimit to set a limit.

Parameters
$patterndef One or more pattern definitions returned by the op.pattern function.
$qualifier Specifies a name for qualifying the column names. By default, triple rows have no qualification. Use cases for the qualifier include self joins. Using an empty string removes all qualification from the column names.
$graphIri A list of graph IRIs to restrict the results to triples in the specified graphs. The sem.defaultGraphIri function returns the iri that identifies the default graph.
$tripleOptions Options consisting of key-value pairs that set options. At present, the options consist of dedup which can take an on|off value to enable or disable deduplication. Deduplication is off by default.

Usage Notes

The fromTriples function is one of the Data Access Functions.

The library functions for building the fromTriples parameters are as follows:

Example


// Returns a list of the people who were born in Brooklyn in the form 
// of a table with two columns, 'person' and 'name'.

const op = require('/MarkLogic/optic');
// prefixer is a factory for sem:iri() constructors in a namespace
const resource   = op.prefixer('http://dbpedia.org/resource/');
const foaf   = op.prefixer('http://xmlns.com/foaf/0.1/');
const onto = op.prefixer('http://dbpedia.org/ontology/');

const person = op.col('person');

const Plan =
    op.fromTriples([
        op.pattern(person, onto('birthPlace'), resource('Brooklyn')),
        op.pattern(person, foaf("name"), op.col("name"))
    ])
Plan.result(); 
  

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