sparqlfusekiapache-jenanamed-graphs

How to query a named graph in Apache Jena Fuseki server


I am laoding a .ttl file into the Jena Fuseki server and instead of the default graph I am using the named graph <http://examples/test>.

/home/user/jena-fuseki-1.1.1/./s-put http://192.168.1.38:3030/ds/data http://example/test /home/user/testdata.ttl

I am able to load the graph and retrieve result using the following command.

/home/user/jena-fuseki-1.1.1/./s-get http://192.168.1.38:3030/ds/data http://example/test

But when I start querying using the s-query command, it is taking the default unnamed graph. How to make the s-query command work on the named graph.

 /home/user/jena-fuseki-1.1.1/./s-query --service http://localhost:3030/ds/query 'SPARQL Query'

This is doing the query on the default unnamed graph. How to make it work on the named graph <http://example/test>?


Solution

  • To access the named graph in a query, use the GRAPH keyword.

    SELECT ?subject ?predicate ?object
    WHERE {
      GRAPH <http://examples/test>
      {
        ?subject ?predicate ?object
      }
    }
    

    http://www.w3.org/TR/sparql11-query/#queryDataset