ARQ provides two ways to query Linked Data, i.e. remote SPARQL Endpoints. The first one us to use the "sparqlService" method on the QueryExecutionFactory.
E.g.:
QueryExecution qe = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
The other way can be done with a QueryExecutionFactory that is also attached to a Jena Model, however you specifcy the "service" in the SPARQL directly.
E.g.:
QueryExecution qe = QueryExecutionFactory.create(query,model);
Sparql:
SELECT ?s ?p WHERE {
SERVICE <http://dbpedia.org/sparql> {
?s ?p <http://en.wikipedia.org/wiki/Sparql>
}
}
Enjoy traversing the linked data!
There is a slight difference between the two: the first lets you do arbitrary SPARQL and the second only basic graph patterns are sent to the end point ( no solution modifiers DISTINCT, ORDER BY, LIMIT etc. ; although these can be done on the outer query locally ).
ReplyDeleteHi Tim - thanks, I omitted those details. The local/remote processing dichotomy is definitely something that makes the transition of SQL developers to SPARQL developers more challenging. For Groovy SPARQL, I wound up adding the support to initialize off of a Jena Model for this very reason.
ReplyDeleteThe Groovy SPARQL also uses Syntax.syntaxARQ to get things like COUNT and other Jena specifics that might not be widely adopted - but are definitely useful for those working with a fully compatible Jena triple store.