I am trying the tutorials of Jena here. I encounter similar problem with this question, but it does not solve my problem. I've already loaded my data into tdb and when I query with SELECT DISTINCT ?g {GRAPH ?g {}}
, the results are as follows:
-----------------
| g |
=================
| <ds-ng-1.ttl> |
| <ds-ng-2.ttl> |
-----------------
but when i try to query with following query in tdb I've got no results.
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <.>
SELECT ?title
{
GRAPH :ds-ng-2.ttl
{ ?b dc:title ?title }
}
According to the similar question I've mentioned above, @RobV mentioned
If you get an absolute URI back then you can specify that directly in your original query, if you do not then there is no way to query for it from the command line.
I'd like to ask is it real? If so, how can I use API to execute this query? My codes are as follows:
String directory = "path_to\\datasets\\data_graph\\tdbtest";
Dataset dataset = TDBFactory.createDataset(directory);
Model tdb = dataset.getDefaultModel();
String queryString = "PREFIX dc:<http://purl.org/dc/elements/1.1/> \nPREFIX : <.> \nSELECT ?title { GRAPH :ds-ng-2.ttl { ?b dc:title ?title }}";
Query query = QueryFactory.create(queryString);
try(QueryExecution qexec = QueryExecutionFactory.create(query, tdb)){
ResultSet results = qexec.execSelect();
ResultSetFormatter.out(System.out, results, query) ;
}
But I still get now results. I'm not sure how I can select multiple models no matter it's a default or named model.