gbv / subjects-api

JSKOS Concept Occurrences Provider implementation
https://coli-conc.gbv.de/subjects/
MIT License
0 stars 0 forks source link

Add Neo4J backend #50

Open nichtich opened 3 weeks ago

nichtich commented 3 weeks ago

Subjects and occurences can also be retrieved from a Neo4J (or compatible) Property Graph database. Requires documentation of the database model and CYPHER queries for each query type. The backend graph is going to be created anyway with https://github.com/gbv/k10plus-graph

MontyBitto commented 3 weeks ago

CYPHER queries for each query type:

occurrences
MATCH (t:title)-[]->(n:?) WHERE n.notation = "?" RETURN count(t) AS freq

coOccurrences
MATCH (t:title)-[]->(n:?) WHERE n.notation = "?" MATCH (t)-[]->(m:?) RETURN head(LABELS(m)), m.notation, count(m) AS freq

subjects
MATCH (t:title)-[]->(n) WHERE t.ppn = "?" RETURN head(LABELS(n)), n.notation

records
MATCH (t:title)-[]->(n:?) WHERE n.notation = "?" RETURN t.ppn LIMIT ?

CYPHER queries with their respective sample query:

occurrences of RVK DG 9000
MATCH (t:title)-[]->(r:rvk) WHERE r.notation = "DG 9000" RETURN count(t)

co-occurrences of RVK DG 9000 in BK
MATCH (t:title)-[]->(r:rvk) WHERE r.notation = "DG 9000" MATCH (t)-[]->(b:bk) RETURN head(LABELS(b)), b.notation, count(b)

co-occurrences of RVK DG 9000 in all vocabularies
MATCH (t:title)-[]->(r:rvk) WHERE r.notation = "DG 9000" MATCH (t)-[]->(n) WHERE not LABELS(n) = ["rvk"] RETURN head(LABELS(n)), n.notation, count(n)

co-occurrences of RVK DG 9000 in all vocabularies (including RVK)
MATCH (t:title)-[]->(r:rvk) WHERE r.notation = "DG 9000" MATCH (t)-[]->(n) RETURN head(LABELS(n)), n.notation, count(n)

subjects of a record (all vocabularies)
MATCH (t:title)-[]->(n) WHERE t.ppn = "012401471" RETURN head(LABELS(n)), n.notation

subjects of a record (selected vocabulary)
MATCH (t:title)-[]->(r:rvk) WHERE t.ppn = "012401471" RETURN head(LABELS(r)), r.notation

records of a subject
MATCH (t:title)-[]->(b:bk) WHERE b.notation = "20.04" RETURN t.ppn