I am looking to run a SPARQL query over any dataset. We dont know the names of the named graphs in the datasets.
These are lots of documentation and examples of selection from named graphs when you know the name of the named graph/s. There are examples showing listing named graphs.
We are running the Jena from Java so it would be possible to run 2 queries, the first gets the named graphs and we inject these into the 2nd.
But surely you can write a single query that reads from all named graphs when you dont know their names?
Note: we are looking to stay away from using default graph/s as their behaviour seems implementation dependent.
Example:
If you want the pattern to match within one graph and wish to try each graph, use the GRAPH ?g form.
If you want to make a query where the pattern matches across named graphs, -- e.g.
foaf:namein one graph andvCard:nicknamein another, same subject -- then set union default graphtdb2:unionDefaultGraph truethen the default graph as seen by the query is the union (actually, RDF merge - no duplicates) of all the named graphs. Use the pattern as originally given.Fuseki configuration file extract:
In code, not Fuseki, the application can use
Dataset.getUnionModel().