wiki:SparqlEndpoint

SPARQL Endpoint

The dataset can be queried via a SPARQL endpoint. At the moment it is driven by 4store.

Tools for running queries

The following examples execute the following very simple SPARQL query for one arbitrary triple from our SPARQL endpoint:

SELECT * {?s ?p ?o} LIMIT 1

Later, we will provide semantically meaningful examples, in a different place.

Jena/ARQ

  1. Download the latest version of  Jena from  SourceForge
  2. Set up your Java class path, so that it includes all of Jena's *.jar libraries except those for testing (jena-*-tests.jar and junit.jar)
  3. Run the arq.remote commandline tool
  4. Help is available with remote --help

Define an alias

It is recommended to define an alias for the lengthy command line in your shell. The following code assumes that the JENA variable points to the lib subdirectory of the directory to which you extracted Jena.

alias remote="java -cp $JENA/arq-2.8.7.jar:$JENA/icu4j-3.4.4.jar:$JENA/iri-0.8.jar:$JENA/jena-2.6.4.jar:$JENA/jena-2.6.4-tests.jar:$JENA/junit-4.5.jar:$JENA/log4j-1.2.13.jar:$JENA/lucene-core-2.3.1.jar:$JENA/slf4j-api-1.5.8.jar:$JENA/slf4j-log4j12-1.5.8.jar:$JENA/stax-api-1.0.1.jar:$JENA/wstx-asl-3.2.9.jar:$JENA/xercesImpl-2.7.1.jar arq.remote"

Run a query

The following command line assumes that you have defined an alias as explained above, and that your shell is sufficiently modern to support process substitution via <(...), as the -query parameter of remote actually expects a file name, but in this example we don't want to create a file.

$ remote --service=http://sci-class.math.auth.gr:8000/sparql/ --query <(echo "SELECT * {?s ?p ?o} LIMIT 1")
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
| s                                                     | p                                             | o                                                     |
=================================================================================================================================================================
| <http://msc2010.org/resources/MSC/2010/msc2010#32A18> | <http://www.w3.org/2004/02/skos/core#broader> | <http://msc2010.org/resources/MSC/2010/msc2010#32Axx> |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

sparql-query

  1. Check out the  sparql-query sources from github
  2. Compile them using make
  3. Add the sparql-query directory to your PATH, or define a suitable alias for the sparql-query executable.
  4. Help is available with sparql-query --help

Run a query

$ sparql-query http://sci-class.math.auth.gr:8000/sparql/ "SELECT * {?s ?p ?o} LIMIT 1"                                                                        
┌───────────────────────────────────────────────────────┬───────────────────────────────────────────────┬───────────────────────────────────────────────────────┐
│ ?s                                                    │ ?p                                            │ ?o                                                    │
├───────────────────────────────────────────────────────┼───────────────────────────────────────────────┼───────────────────────────────────────────────────────┤
│ <http://msc2010.org/resources/MSC/2010/msc2010#32A18> │ <http://www.w3.org/2004/02/skos/core#broader> │ <http://msc2010.org/resources/MSC/2010/msc2010#32Axx> │
└───────────────────────────────────────────────────────┴───────────────────────────────────────────────┴───────────────────────────────────────────────────────┘