MarkLogic 9 Product Documentation
op.pattern

op.pattern(
   subjects as String,
   predicates as String,
   objects as String,
   [systemCols as String]
) as patterndef

Summary

This function builds the parameters for the op.fromTriples function. The result is passed to op.fromTriples to project rows from the graph of triples. The columns in a pattern become the columns of the row. The literals in a pattern are used to match triples. You should specify at least one literal in each pattern, usually the predicate. Where a column appears in more than one pattern, the matched triples are joined to form the row. You can specify optional triples with a prototype.joinLeftOuter with a separate op.fromTriples .

Parameters
subjects One column or one or more literal values, such as the literal returned by a sem.iri call.
predicates One column or one or more literal values, such as the literal returned by a sem.iri call.
objects One column or one or more literal values, such as the literal returned by a sem.iri call.
systemCols Specifies the result of an op.fragmentIdCol or op.graphCol function to add columns for the fragment id or graph iri.

Example


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"))
    ])
    .select();
Plan.result(); 
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy