BlazeGraphSPARQLHowto

Dan Brickley edited this page Aug 26, 2016 · 9 revisions

This is a quick writeup showing how to load up the schema.org data dumps into Blazegraph, one of several implementations of the W3C SPARQL query language.

Install Blazegraph

You will need Java, and then you'll need to download and set up BlazeGraph. For me on OSX all I then needed was to download their blazegraph.jar file and run it from the commandline with a particular chosen (database) port:

java -Djetty.port=7777 -jar blazegraph.jar

This brings up an empty database server on my local machine (on a different port - see Blazegraph output to be sure which but default seems to be 9999), accessible at http://localhost:9999/blazegraph/

Load Schema.org data dumps

Next we will need to load the latest schema.org data, in nquads format. See http://schema.org/docs/developers.html for more options. The nquads version is organized into "sub graphs" for each section of the site, and is available from http://schema.org/version/latest/all-layers.nq

  1. Use the "type" dropdown, select "File path or URL".
  2. Paste http://schema.org/version/latest/all-layers.nq into the main textarea.
  3. Set format to N-Quads.
  4. Load the data via "Update" button.

If you prefer all schemas mixed together with no graphs, other data dumps can be used.

Initial blazegraph data loading screen

## Query Schema.org definitions using W3C SPARQL

Now we can enter SPARQL queries. Here is a simple query asking for pairs of types where one is a subclass of another.

SELECT ?type1 ?type2 ?g where { GRAPH ?g { ?type1 rdfs:subClassOf ?type2 . } }

Example query

Here is another more sophisticated query:

select * where { graph ?g { ?x rdf:type/rdfs:subClassOf? <http://schema.org/Enumeration> . } }

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.