Skip to main content

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.

Session 8 of Going Meta, broadcast on September 6, 2022, is a practical survey of the most frequently encountered RDF integration scenarios when working with Neo4j. Jesus walks through importing RDF embedded in HTML pages, enriching an existing property graph with data pulled from the DBpedia SPARQL endpoint, and previewing RDF payloads before committing them — covering the full lifecycle from raw data ingestion to linked-data enrichment.

What You Will Learn

  • How to extract and preview JSON-LD embedded in live web pages using apoc.load.html and n10s.rdf.preview.inline
  • How to configure Neo4j for RDF import with n10s.graphconfig.init
  • How to query a remote SPARQL endpoint (DBpedia) and consume the CSV result set in Cypher
  • How to iterate over nodes and parameterize SPARQL queries with graph data
  • How to combine n10s.rdf.import.fetch with APOC URL encoding to batch-enrich nodes from linked data
Tags: Cypher · JSON-LD · SPARQL — Broadcast September 6, 2022

Pattern 1 — Import RDF Embedded in HTML

Many modern web pages embed structured data as JSON-LD in <script> tags. APOC’s HTML loader can extract it, and n10s can immediately parse and preview the RDF graph.
CALL apoc.load.html(
  "https://www.theguardian.com/technology/2022/sep/01/twitter-to-allow-users-to-edit-tweets-after-posting",
  { jsonld: 'head script[type="application/ld+json"]'}
) YIELD value
WITH value.jsonld[0].data AS rdf
CALL n10s.rdf.preview.inline(rdf, "JSON-LD") YIELD nodes, relationships
RETURN nodes, relationships
Using n10s.rdf.preview.inline (instead of import) lets you inspect the nodes and relationships that would be created before committing — a safe first step for any new data source.

Pattern 2 — Enrich Nodes from a SPARQL Endpoint

1

Load the starter graph

Use the built-in Movies dataset as a starting point:
:play movies
2

Configure the RDF importer

Set the graph configuration so vocabulary URIs are mapped to simple names:
CALL n10s.graphconfig.init({handleVocabUris: "IGNORE"})
3

Inspect the DBpedia SPARQL query

This SPARQL query fetches the birth date and place for a named actor from DBpedia:
SELECT *
WHERE {
  [] rdfs:label "Harrison Ford"@en ;
     dbp:birthDate ?birthDate ;
     dbp:birthPlace ?birthPlace .
}
4

Parameterize and execute for all actors

Iterate over every Person node that has acted in a movie, substitute their name into the query, and retrieve results as a CSV stream:
WITH 'https://dbpedia.org/sparql/?default-graph-uri=http%3A%2F%2Fdbpedia.org&format=text%2Fcsv&query=' AS endpoint,
'SELECT *
WHERE {
[] rdfs:label "<<name>>"@en ;
   dbp:birthDate ?birthDate ;
   dbp:birthPlace ?birthPlace .
}' AS query

MATCH (a:Person) WHERE (a)-[:ACTED_IN]->()

LOAD CSV WITH HEADERS FROM endpoint + apoc.text.urlencode(replace(query,"<<name>>", a.name)) AS row
RETURN a, row
The key trick is apoc.text.urlencode(replace(query, "<<name>>", a.name)) — this turns a parameterized SPARQL string into a valid HTTP query parameter, letting you use LOAD CSV as a universal HTTP client against any endpoint that returns CSV.

Pattern 3 — Previewing RDF Before Import

Before writing any data, n10s.rdf.preview.inline or n10s.rdf.preview.fetch returns the nodes and relationships that would be created, so you can verify the shape of the incoming graph without touching the database. This pattern applies equally to Turtle, JSON-LD, N-Triples, and RDF/XML serializations.

Resources

Watch the Recording

Full live-stream on YouTube — Session 8, September 6 2022

Source Code on GitHub

Cypher scripts and RDF integration examples

Build docs developers (and LLMs) love