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 1 of Going Meta (broadcast February 1, 2022) takes the British National Bibliography (BNB) — a rich, openly published RDF dataset from the British Library — and loads it into Neo4j using the neosemantics (n10s) plugin. Once the data is in the graph, Jesús walks through a set of practical questions answered with both Cypher and SPARQL, making it easy to compare the two query languages on identical problems with real data.

What You Will Learn

  • How to download the BNB catalog in N-Triples format and import it into Neo4j with n10s
  • Setting up the n10s graph configuration (handleVocabUris: "IGNORE") for a clean property-graph representation
  • Writing Cypher MATCH patterns and their SPARQL SELECT/WHERE equivalents
  • Using CONTAINS / regex() for partial-string search in both languages
  • Aggregating and grouping results — count, collect in Cypher; COUNT, GROUP_CONCAT in SPARQL

Importing the British Library Catalog

1

Download the BNB dataset

Go to the British Library downloads page and download the British National Bibliography (BNB) Books LOD in N-Triples format. Unzip the archive locally.
2

Install neosemantics (n10s)

Install n10s from the Neo4j Desktop plugins panel, or follow the manual installation guide.
3

Create the uniqueness constraint

CREATE CONSTRAINT n10s_unique_uri ON (r:Resource)
ASSERT r.uri IS UNIQUE;
4

Initialise the graph config

CALL n10s.graphconfig.init({ handleVocabUris: "IGNORE" });
5

Import the RDF files

The BNB download contains numbered files. The snippet below imports files 101 through 149 in a single loop — adjust the absolute path to match your local download folder.
UNWIND range(101,149) AS id
WITH "BNBLODB_202112_f" + substring(tostring(id),1) + ".nt" AS filename
CALL n10s.rdf.import.fetch(
  "file:///<absolute path to your downloads folder>/bnb/" + filename,
  "N-Triples"
) YIELD terminationStatus, triplesLoaded, triplesParsed, extraInfo
RETURN filename, terminationStatus, triplesLoaded, triplesParsed, extraInfo;

Cypher vs. SPARQL: Side-by-Side Examples

Each example below solves the same question in both query languages so you can see how patterns, filters, and aggregations map from one to the other.

Look Up a Book by ISBN

MATCH (b:Book { isbn13: "9780729412261" })
RETURN b.uri, b.bnb, b.title

All Books by Ian Rankin

MATCH (:Person { name: "Ian Rankin" })<-[:creator]-(b:Book)
RETURN DISTINCT b.title AS t
ORDER BY t DESC
MATCH (p:Person)<-[:creator]-(b:Book)
WHERE p.name CONTAINS "Rankin"
RETURN DISTINCT p.name AS name, b.title AS title
ORDER BY name, title DESC

Most Prolific Authors on a Subject

MATCH (:Concept { label: "Crystallography" })<-[:subject]-(cb:Book)-[:creator]->(auth:Person)
RETURN auth.label AS auth,
       count(DISTINCT cb.title) AS bookcount,
       collect(DISTINCT cb.title) AS booklist
ORDER BY bookcount DESC
MATCH (:Concept { label: "Crystallography" })-[:subject]-(b:Book)-[:subject]-(related:Concept:TopicLCSH)
RETURN related.label AS relatedconcept, count(b) AS coocurence
ORDER BY coocurence DESC
The co-occurrence pattern above finds SKOS concepts that share books with Crystallography. This is an informal measure of subject similarity and is a precursor to the semantic search techniques explored in Session 2.

Resources

Watch the Recording

Full live-stream recording of Going Meta Session 1 on YouTube.

Session Code on GitHub

All queries and import scripts used in this session.

Build docs developers (and LLMs) love