Session 18 of Going Meta, broadcast on July 4, 2023, tackles a question that arises whenever organisations evaluate Neo4j alongside existing RDF infrastructure: can you move a full knowledge graph — ontology, data, and all — out of a triple store and into Neo4j without losing fidelity? Jesus Barrasa walks through Python notebooks that do exactly this for three popular RDF stores: Stardog (Apache Jena-based), Ontotext GraphDB, and Amazon Neptune, using rdflib and neosemantics.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jbarrasa/goingmeta/llms.txt
Use this file to discover all available pages before exploring further.
What You’ll Learn
- How to extract a full RDF graph from Stardog, Ontotext GraphDB, or Amazon Neptune via their SPARQL endpoints
- How to load the exported data into Neo4j using neosemantics (n10s)
- How to verify that the migrated graph on the Neo4j side is identical to the source
- How to cross-check data with equivalent SPARQL and Cypher queries
Migration Targets Covered
Stardog (Apache Jena)
The first part of the notebook demonstrates exporting data from a Stardog instance and importing it into Neo4j, using the music/Nirvana tutorial dataset.
Ontotext GraphDB
The second part covers migration from GraphDB using the Industry 4.0 Standards Ontology (I4.0KG), a production-grade semantic dataset.
Amazon Neptune
A companion notebook (
neptune_migration.ipynb) demonstrates the same pattern against an Amazon Neptune SPARQL endpoint, using a CONSTRUCT query to extract all triples and load them into Neo4j via the Python driver.Step-by-Step Walkthrough
Explore source data with SPARQL (Stardog)
Before migrating, verify the source data by running SPARQL queries directly against Stardog Studio. For example, to inspect all triples about Nirvana:Then check everything related to a specific song:
Run the migration notebook (Part 1 — Stardog)
Execute the first section of the Python notebook (
Easy_full_graph_migration_from_triple_stores.ipynb). The notebook uses rdflib to pull the full graph from Stardog and neosemantics to insert it into Neo4j.Verify the migration in Neo4j (Cypher)
After the migration, confirm the data landed correctly by querying for the same “Shake It Off” subgraph in Cypher:You can also export the Neo4j data back as RDF N-Triples to compare with the source:
Run the migration notebook (Part 2 — Ontotext)
Execute the second section of the notebook to migrate data from the Ontotext GraphDB I4.0KG endpoint. You can test the source with a SPARQL query on the public endpoint:
Why This Matters
Full-Fidelity Migration
neosemantics preserves RDF semantics — classes, properties, and ontology axioms — so you don’t lose meaning when moving to Neo4j’s property graph model.
Bidirectional Verification
Exporting the Neo4j graph back as RDF N-Triples lets you byte-compare against the original triple store, giving high confidence in migration completeness.
Works Across Vendors
The same Python notebook pattern works with any SPARQL 1.1-compliant triple store — not just Stardog, Ontotext, and Amazon Neptune.
Preserves Ontology Structure
Class hierarchies, property domains/ranges, and OWL axioms are imported alongside data, so ontology-based reasoning remains possible in Neo4j.
The main Python notebook for this session is
session18/Easy_full_graph_migration_from_triple_stores.ipynb — Part 1 covers Stardog, Part 2 covers Ontotext. A separate companion notebook session18/neptune_migration.ipynb covers Amazon Neptune.Resources
Watch the Recording
Full session recording on YouTube — July 4, 2023.
Session Code
Python notebook and Cypher queries on GitHub.