MarkLogic Server 11.0 Product Documentation
sem.sparqlValues

sem.sparqlValues(
   sparql as String,
   values as Object[],
   [options as String[]],
   [store as Sequence]
) as Sequence

Summary

This function executes a SPARQL SELECT query using passed-in bindings participating as a starting point for the query.

Parameters
sparql The SPARQL query to be executed. Must be a SELECT query form.
values A map containing initial bindings for variables used in the query. Unlike sem:sparql, a sequence of bindings is acceptable and will be processed as the equivalent of an outermost VALUES block in the query.
options Query options. Valid options values include:
"base=IRI"
The initial base IRI for the query.
"default-graph=IRI*"
Add the named graph or graphs specified by the IRI to the default graph for the query.
"named-graph=IRI*"
Add the named graph or graphs specified by the IRI to the list of named graphs available in the query.
"optimize=N"
Sets the optimization level to use. Levels of 0 (off), 1, and 2 are recognized. Default is 1.
store Options for "any", "document", "properties", "locks", "checked", and "unchecked", which used to be part of the sem:sparql-values signature, must be specified as part of sem:store, not as part of sem:sparql-values. This parameter is designed to take sem:store*, but is typed as an item()* for backward compatibility. The default for sem:store is the current database's triple index, restricted by the options and the cts:query argument (for instance, "triples in documents matching this query").

The locking option specified in sem:store will be used by sem:sparql-values. Locking is ignored in a query transaction.

If a sem:store value is not supplied, then the default sem:store for the statement will be used. This is the same as calling sem:store() with all arguments omitted, which will access the current database's triple index, using the default rulesets configured for that database. The default for locking is read-write.

Usage Notes

If $values is an empty sequence, nothing is returned.

A variable can be in both bindings and the VALUES clause.

The binding variable must occur in either the SELECT clause or the triple patterns, otherwise an "Undefined variable" exception is thrown.

The sem:sparql-values function performs a join (SPARQL style, natural join) between the bindings returned from the SELECT expression and the bindings passed in as an argument, therefore the results reflect this join.

Example

const sem = require("/MarkLogic/semantics.xqy");

const bindings = [
  {"s": sem.iri("http://example.net/foaf.rdf#Lenovo_T61")},
  {"s": sem.iri("http://example.net/foaf.rdf#Nokia_N80")}
  ];
sem.sparqlValues("select * where { ?s ?p ?o }", bindings);

    
Powered by MarkLogic Server | Terms of Use | Privacy Policy