Named Graph and Dereferentiation

Hi all, some implementations of sparql dereferentiate the content from a uri on FROM NAMED GRAPH.

select *
FROM NAMED http://somedomain.com/example.nt
WHERE {
?s ?p ?o
}

That would return all triples in example.nt

Why stardog does not do so? Is there a away to query a remote file (eg. .nt)?

There’re two things here: first, Stardog won’t dereference IRIs in FROM NAMED or FROM clauses. Those should be used with named graphs in the data. If you want to query remote sources, you can use the SERVICE keyword (assuming there’s a SPARQL endpoint to serve requests). Second, this query wouldn’t return results even if example.nt was a local named graph. Since your triple pattern is not within a graph ?g {...} block, you should use FROM.

Best,
Pavel

You could get something very close to what you’re looking for with a quick bash command

$> URI="http://somedomain.com/example.nt
$> stardog data add myDb --named-graph $URI <(curl -s $URI)

I haven’t had a chance to test it but if it’s not correct it should be close. You might need to be explicit with the file type and add “-format NTRIPLES” . Hope that helps :slight_smile:

By the way, I believe the original query is not correct: when using FROM NAMED (as opposed to FROM) you need to actually name the graph in the query. For example:
SELECT * FROM NAMED <http://somedomain.com/example.nt> WHERE { GRAPH <http://somedomain.com/example.nt> {?s ?p ?o} }

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.