BlazeGraphSPARQLHowto
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.
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/
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
- Use the "type" dropdown, select "File path or URL".
- Paste http://schema.org/version/latest/all-layers.nq into the main textarea.
- Set format to N-Quads.
- Load the data via "Update" button.
If you prefer all schemas mixed together with no graphs, other data dumps can be used.
## 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 . } }
Here is another more sophisticated query:
select * where { graph ?g { ?x rdf:type/rdfs:subClassOf? <http://schema.org/Enumeration> . } }
- See also http://query.wikidata.org/ for a similar installation for Wikidata's dataset.
- Version 3.1 of Schema.org is available at Dydra for online query.
- Schema.org's unit tests are largely expressed in SPARQL; see tests folder for details.