FROM is for a different use: https://jena.apache.org/tutorials/sparql_datasets.html#describing-rdf-datasets-from-and-from-named
--- A. Soroka The University of Virginia Library > On Apr 11, 2017, at 5:20 AM, Andy Seaborne <[email protected]> wrote: > > > > On 11/04/17 01:29, Dimov, Stefan wrote: >> Another question in that order: >> >> Now: >> >> SELECT count(*) >> FROM <http://ao.com/namedGraph/aaa> >> { >> { ?s ?p ?o } >> } >> >> returns the number of the triples in aaa, correctly, but: >> >> SELECT count(*) >> FROM NAMED <http://ao.com/namedGraph/aaa> >> { >> { ?s ?p ?o } >> } >> > > If you are querying the dataset, you don't need FROM / FROM NAMED: use GRAPH > to access a named graph: > > SELECT count(*) > { > GRAPH <http://ao.com/namedGraph/aaa> > { ?s ?p ?o } > } > > Andy > >> returns zero. >> >> The explanation (in the docs) of the difference between FROM and FROM NAMED >> is a bit confusing and it’s not enough (for me) to understand, why the first >> is working and the second is not … >> >> S. >> >> On 4/10/17, 5:09 PM, "Dimov, Stefan" <[email protected]> wrote: >> >> Got it - it’s gotta be a real URI, with http and everything: >> >> http://ao.com/aaa >> >> The simple names, like: >> >> aaa >> >> don’t work … >> >> S. >> >> >> On 4/10/17, 4:22 PM, "Dimov, Stefan" <[email protected]> wrote: >> >> I (almost) got it. >> >> Apparently, the data was loaded correctly. Now I can query the names >> of all the graphs: >> >> SELECT DISTINCT $g >> { >> GRAPH ?g { ?s ?p ?o } >> } >> >> returns: >> >> { >> "head": { >> "vars": [ "g" ] >> } , >> "results": { >> "bindings": [ >> { >> "g": { "type": "uri" , "value": "aaa" } >> } , >> { >> "g": { "type": "uri" , "value": "bbb" } >> } , >> { >> "g": { "type": "uri" , "value": "ccc" } >> } , >> { >> "g": { "type": "uri" , "value": "ddd" } >> } , >> … >> >> or the data: >> >> SELECT count(*) >> { >> GRAPH ?g { ?s ?p ?o } >> } >> >> returns: >> >> { >> "head": { >> "vars": [ ".1" ] >> } , >> "results": { >> "bindings": [ >> { >> ".1": { "type": "literal" , "datatype": >> "http://www.w3.org/2001/XMLSchema#integer" , "value": "395721" } >> } >> ] >> } >> } >> >> but I still can’t figure out how to query specific named graph. This: >> >> SELECT count(*) >> { >> GRAPH <aaa> { ?s ?p ?o } >> } >> >> should work. But actually it returns zero results: >> >> { >> "head": { >> "vars": [ ".1" ] >> } , >> "results": { >> "bindings": [ >> { >> ".1": { "type": "literal" , "datatype": >> "http://www.w3.org/2001/XMLSchema#integer" , "value": "0" } >> } >> ] >> } >> } >> >> Any idea? >> >> S. >> >> >> On 4/10/17, 2:06 PM, "Dimov, Stefan" <[email protected]> wrote: >> >> Hi, >> >> I’m using in-mem base and loading multiple named graphs in one >> data set, iterating thru : >> >> private static boolean loadGraphT(Dataset ds) { >> … >> String filename = … >> String graphName = … >> … >> Model model = ds.getNamedModel(graphName); >> ds.begin(ReadWrite.WRITE); >> FileManager.get().readModel(model, fileName); >> ds.commit(); >> ds.end(); >> return true; >> } >> >> >> >> At start, after everything is read and data set is committed, I’m >> printing out the graph names and their sizes, to check, if everything was >> loaded: >> >> 2017-04-10 13:50:50 INFO Ontology:50 - Named graph aaa - 7855 >> triples >> 2017-04-10 13:50:50 INFO Ontology:50 - Named graph bbb - 26 >> triples >> 2017-04-10 13:50:50 INFO Ontology:50 - Named graph ccc - 4 >> triples >> 2017-04-10 13:50:50 INFO Ontology:50 - Named graph ddd - 20000 >> triples >> … >> >> After that I’m trying to query some data from a named graph: >> >> SELECT count ($s) >> FROM NAMED <aaa> >> { >> { ?s ?p ?o } >> } >> >> or trying to query it without specifying graph: >> >> SELECT count ($s) >> { >> { ?s ?p ?o } >> } >> >> The result is empty: >> >> { >> "head": { >> "vars": [ ".1" ] >> } , >> "results": { >> "bindings": [ >> { >> ".1": { "type": "literal" , "datatype": >> "http://www.w3.org/2001/XMLSchema#integer" , "value": "0" } >> } >> ] >> } >> } >> >> What am I doing wrong? >> >> S. >> >> >> >> >> >>
