Rdfstore 2.0 Docs -- Specific Triplestores


Specific documentation for using Rdfstore with individual triplestores.

You only need one triplestore behind Rdfstore.
» If you want performance, you should use Virtuoso.
» If you want ease-of-use, you should use Fuseki.

Table of Contents

» Virtuoso

» Fuseki

Virtuoso


When your server is running Virtuoso, by default the SPARQL endpoint is on port 8890. In the following documentation, we'll assume you keep that default; if you change it to another port, then change everything accordingly.

Queries

Depending on what format you'd like the results in, you can use one of the following strings as the "endpoint" when running Rdfstore.

JSON format

» Endpoint string:

        http://localhost:8890/sparql?default-graph-uri=&format=application%2Fsparql-results%2Bjson&timeout=0&debug=on&query=
      
» Minimum working example commandline:
        java Rdfstore -endpoint "http://localhost:8890/sparql?default-graph-uri=&format=application%2Fsparql-results%2Bjson&timeout=0&debug=on&query="
      

HTML format

» Endpoint string:

      http://localhost:8890/sparql?default-graph-uri=&format=text%2Fhtml&timeout=0&debug=on&query=
      
» Minimum working example commandline:
        java Rdfstore -endpoint "http://localhost:8890/sparql?default-graph-uri=&format=text%2Fhtml&timeout=0&debug=on&query="
      

Other formats

Virtuoso makes a lot of other formats available. To see the list, go to this Virtuoso SPARQL documentation page and scroll down to "16.2.3.3.3. Response Format".

For each listed content type, the general formula for the endpoint string is:

        http://localhost:8890/sparql?default-graph-uri=&format=(content type)&timeout=0&debug=on&query=
      
where (content type) is replaced by the url-encoded mimetype from the above link.
Example:
Suppose you want the format as "application/x-turtle".
Urlescape to get: "application%2Fx-turtle".
The endpoint string is:
          http://localhost:8890/sparql?default-graph-uri=&format=application%2Fx-turtle&timeout=0&debug=on&query=
        

Adding triples

There are two things to know to set up triple-authoring via Rdfstore via Virtuoso.

Must specify graph

When adding a triple in Virtuoso, it is necessary to specify which graph it goes in. Here's an example "Insert_Triple.txt" template:

        # 0 = Graph IRI
        # 1 = Subject IRI
        # 2 = Predicate IRI
        # 3 = Object IRI
        INSERT INTO <[0]>
        {
          <[1]>
          <[2]>
          <[3]>
        }
      
(Note: The four comments at the beginning are just to tell the GUI what placeholder text to put in the blank fields; they aren't strictly necessary.)

Must grant permission

By default, Virtuoso forbids triple-insertion via SPARQL endpoint. If triple-insertion is forbidden, then your triple-insert Rdfstore templates will fail.

Here's how to enable triple-insertion via SPARQL endpoint:

  1. Connect to Virtuoso's ISQL console. From the commandline on the machine where Virtuoso is running, this is usually done with the "isql" command (or "isql-vt" on Ubuntu).
  2. Issue the command:
                GRANT execute ON SPARQL_INSERT_DICT_CONTENT TO "SPARQL";
              
  3. You might be prompted for your Virtuoso credentials; if so, enter them.
  4. Issue the command:
                GRANT execute ON SPARQL_INSERT_DICT_CONTENT TO SPARQL_UPDATE;
              
  5. If you also want to enable templates to delete triples, issues the following commands as well:
                GRANT execute ON SPARQL_DELETE_DICT_CONTENT TO "SPARQL"
                GRANT execute ON SPARQL_DELETE_DICT_CONTENT TO SPARQL_UPDATE;
              

Note: If you are worried about the security implications of allowing triple-insertion via SPARQL endpoint, our recommendation is as follows. You should configure your machine so that only localhost is permitted to connect to port 8890 (or whichever port Virtuoso is running on). Then, you can perform proper validation of user input in whatever program it is you're designing, before invoking the Rdfstore API.

Fuseki


See also: How to bulkload data in Fuseki

By default, the Fuseki triple-store runs a SPARQL endpoint on port 3030. If you're running Fuseki on some other port, change everything accordingly.

When using Fuseki, one gives one's dataset a name, and that name has to be inserted into the SPARQL endpoint URL. For the documentation below, we will assume your dataset is named "dataset". If you use a different name, change everything accordingly.

Queries

Depending on what format you like, you can run Rdfstore with the following endpoint strings.

JSON

» Endpoint string:

        http://localhost:3030/dataset/query?force-accept=text%2Fplain&output=json&query=
      
» Minimum working example commandline (query only, no update support):
        java Rdfstore -endpoint "http://localhost:3030/dataset/query?force-accept=text%2Fplain&output=json&query="
      
» Remember to change "dataset" to the actual name of your Fuseki dataset!

Text

» Endpoint string:

        http://localhost:3030/dataset/query?force-accept=text%2Fplain&output=text&query=
      
» Minimum working example commandline (query only, no update support):
        java Rdfstore -endpoint "http://localhost:3030/dataset/query?force-accept=text%2Fplain&output=text&query="
      
» Remember to change "dataset" to the actual name of your Fuseki dataset!

XML

» Endpoint string:

        http://localhost:3030/dataset/query?force-accept=text%2Fplain&output=xml&query=
      
» Minimum working example commandline (query only, no update support):
        java Rdfstore -endpoint "http://localhost:3030/dataset/query?force-accept=text%2Fplain&output=xml&query="
      
» Remember to change "dataset" to the actual name of your Fuseki dataset!

TSV

» Endpoint string:

        http://localhost:3030/dataset/query?force-accept=text%2Fplain&output=tsv&query=
      
» Minimum working example commandline (query only, no update support):
        java Rdfstore -endpoint "http://localhost:3030/dataset/query?force-accept=text%2Fplain&output=tsv&query="
      
» Remember to change "dataset" to the actual name of your Fuseki dataset!

Adding triples

The Fuseki SPARQL endpoint uses different URLs for SPARQL queries and SPARQL updates. Furthermore, it only accepts SPARQL updates sent with an HTTP POST, it rejects updates sent with HTTP GET.

Fortunately, Rdfstore allows you to specify a separate address/method for updates. Run Rdfstore with commandline options

        -updatemethod POST
      
and
        -update "http://localhost:3030/dataset/update"
      
(replace "dataset" with the actual name of your dataset).

Minimal working example

If you want to run Rdfstore using Fuseki as the triplestore, returning query results in JSON format, and with a dataset named "models", you can run it as follows:

        java Rdfstore -endpoint "http://localhost:3030/models/query?force-accept=text%2Fplain&output=json&query=" -update "http://localhost:3030/models/update" -updatemethod POST