Ontologies are serialised as RDF, so they can be imported using plain importRDF
but the liteOntoImport
method will give us a higher level of control over how an RDFS or OWL ontology is imported into Neo4j. It’s important to
note that this procedure exclusively import the following:
rdfs:Class
and owl:Class
.
rdf:subClassOf
statements.
owl:ObjectProperty
, owl:DatatypeProperty
and rdfs:Property
rdfs:subPropertyOf
statements.
rdfs:domain
and rdfs:range
statements.
All other elments will be ignored by this loader.
The liteOntoImport
procedure takes the same generic params described in ??? at the beginning of the Chapter 3, Importing RDF data section, so we will invoke it with a URL and a serialisation format. In the following example we will import the ontology
in this file.
CALL semantics.importOntology("http://jbarrasa.github.io/neosemantics/docs/rdf/vw.owl","Turtle")
![]() |
As we see in the ingested graph, by default, classes will be persissted as nodes with label Class
with two properties: uri and name and rdf:subClassOf
statements are stored ass relationships of type SCO
between Class
nodes. Similarly, relationships will be persisted as nodes with name and uri and labels Relationship
or Property
for owl:ObjectProperty
and owl:DatatypeProperty
respectively. Statements with rdf:subPropertyOf
as predicate are stored as relationships of type SPO
between Relationship
or Property
nodes.
These graph model elements can be overriden by using the following configuration params:
Class
.
rdfs:subClassOf
hierarchies. Default is SCO
.
Property
.
Relationship
.
rdfs:subPropertyOf
hierarchies. Default is SPO
.
rdfs:domain
. Default is DOMAIN
.
rdfs:range
. Default is RANGE
.
Here’s an example of how to load an ontology using some of these parameters:
CALL semantics.importOntology("http://jbarrasa.github.io/neosemantics/docs/rdf/vw.owl","Turtle", { classLabel : 'Category', objectPropertyLabel: 'Rel', dataTypePropertyLabel: 'Prop'})
Finally, it’s also possible to have imported nodes (both Classes and Properties/Relationships) labeled as Resource
for compatibility with the importRDF procedure. This is done by setting the addResourceLabels
parameter to true
.