Skip to content

Instantly share code, notes, and snippets.

@pierredewilde
Created August 19, 2011 11:44
Show Gist options
  • Save pierredewilde/1156635 to your computer and use it in GitHub Desktop.
Save pierredewilde/1156635 to your computer and use it in GitHub Desktop.
Execute SPARQL on Neo4jGraph via Blueprints SailGraph
\,,,/
(o o)
-----oOOo-(_)-oOOo-----
gremlin> Gremlin.version()
==>1.3-SNAPSHOTgremlin> g = new SailGraph(new GraphSail(new Neo4jGraph('/data/neo4j/ian')))
==>sailgraph[graphsail]
gremlin> g.loadRDF('/data/rdf/ian.rdf', 'rdf-xml')
==>null
gremlin> g.E
==>e[http://example.com/test - rdf:type -> owl:Ontology]
==>e[:hasFeature - rdf:type -> owl:ObjectProperty]
==>e[:hasFeature - rdfs:domain -> :Object]
==>e[:hasFeature - rdfs:range -> :Feature]
==>e[:Object - rdf:type -> owl:Class]
==>e[:Object - rdfs:subClassOf -> owl:Thing]
==>e[:Feature - rdf:type -> owl:Class]
==>e[:Feature - rdfs:subClassOf -> owl:Thing]
==>e[:Power - rdf:type -> owl:Class]
==>e[:Power - rdfs:subClassOf -> :Feature]
==>e[:Height1 - rdf:type -> owl:NamedIndividual]
==>e[:Height1 - rdf:type -> :Feature]
==>e[:Width1 - rdf:type -> owl:NamedIndividual]
==>e[:Width1 - rdf:type -> :Feature]
==>e[:Engine2 - rdf:type -> owl:NamedIndividual]
==>e[:Engine2 - rdf:type -> :Object]
==>e[:Engine2 - :hasFeature -> :Height1]
==>e[:Engine3 - rdf:type -> owl:NamedIndividual]
==>e[:Engine3 - rdf:type -> :Object]
==>e[:Engine3 - :hasFeature -> :Width1]
==>e[:Engine1 - rdf:type -> owl:NamedIndividual]
==>e[:Engine1 - rdf:type -> :Object]
==>e[:Engine1 - :hasFeature -> :Power1]
==>e[:Power1 - rdf:type -> owl:NamedIndividual]
==>e[:Power1 - rdf:type -> :Feature]
gremlin> x1 = "SELECT ?object ?feature WHERE {?object a test:Object . ?object test:hasFeature ?feature . }"
==>SELECT ?object ?feature WHERE {?object a test:Object . ?object test:hasFeature ?feature . }
gremlin> g.executeSparql(x1)
==>{feature=v[http://example.com/test#Height1], object=v[http://example.com/test#Engine2]}
==>{feature=v[http://example.com/test#Width1], object=v[http://example.com/test#Engine3]}
==>{feature=v[http://example.com/test#Power1], object=v[http://example.com/test#Engine1]}
gremlin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment