SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Document oriented access
to a graph database
Using a Neo4j Server Extension
Michael Hunger - @mesirii
http://github.com/jexp/cypher-rs
Graphs
Graphs are great
• for modeling highly connected domains
• finding patterns to answer questions
• high performance traversals
Graphs are great
Graphs suck
• for compact access patterns
• use-case specific views
• easy integration in modern webapps
Graphs suck
Documents
Documents are great
• for everything that eats JSON
• especially modern JavaScript based webapps
• as dedicated projections of a domain
• compact representation
Documents are great
{
name:"Michael",
age:39,
children:[„Selina“,“Rana“,"Selma"],
address: { street: „Holbeinstr“, city: „Dresden“}
hobbies: [„Coding“,„Buchbar“,“MUD MorgenGrauen“]
blog: „http://jexp.de/blog“
}
Documents suck
• for different projections besides the main use-case
• for connected data
• for cross-document linking
• for less redundancy / duplication
Documents suck
{
name:"Michael",
age:39,
children:[„Selina“,“Rana“,"Selma"],
address: { street: „Holbeinstr“, city: „Dresden“}
hobbies: [„Coding“,„Buchbar“,“MUD MorgenGrauen“]
blog: „http://jexp.de/blog“
}
„Show people by hobby“
Documents suck
{ _id: 1,
name:“Michael“,
works_at: dbref:2
}
{ _id: 2,
name:“Neo Technology“,
employees: [dbref:1]
}
„Link Employees to Companies“
What can we do?
• Use a document oriented access layer for a graph database
• Use graph queries whose results project into documents
• Make them easily accessible
How can we do that?
• Use Cypher in Neo4j 2.0
• Support for literal maps
• Parameters, including maps
Cypher Maps
Cypher & Maps - Results
MATCH (n:User)
WHERE n.name={name}
RETURN n
// returns a map of the node’s properties
RETURN {id: id(n), labels: labels(n), data : n}
Cypher & Maps - Results (II)
MATCH (n:User)-[:PARENT_OF]->(child)
WHERE n.name={name}
RETURN {name:n.name, children:collect(child.name)}
Cypher & Maps - Params
CREATE (u:User { name: {p}.name, age: {p}.age})
RETURN u
CREATE (u:User {params})
RETURN u
Some Questions
How can we do that?
• Create a RESTful API to
• Provide endpoints that represent on Cypher queries
• Use GET, POST with parameters to execute those endpoints
• Return only JSON documents or lists of those
How do we implement it?
• Add a Neo4j-Server-Extension
• Jersey JAX-RS
• Save queries in graph properties
• Execute queries for reads on GET
• Execute queries for reads and writes on POST
• Support JSON and CSV as payload
• Batch transactional write operations
What does it look like?
What does it look like?
• Examples for
• Managing endpoints
• Querying Endpoints
• Writing to Endpoints
Create Endpoint
PUT /cypher-rs/users
Body: match (n:User) where n.name={name} return n
--> 201 Location: /cypher-rs/users
PUT /cypher-rs/create-user
Body: create (n:Node {name:{name},age:{age}})
--> 201 Location: /cypher-rs/create-user
GET, POST - Reads
GET Request
GET /cypher-rs/users?name=Andres
--> 200
{"name":"Andres",
"age":21,"children":["Cypher","L.","N."]}
GET /cypher-rs/users?name=NotExists
--> 204
POST Request - Read
POST /cypher-rs/users
Content-type: application/json
Body: {"name":"Andres"}
--> 200
{"name":"Andres","age":21,
"children":["Cypher","L.","N."]}
POST Request - Read (II)
POST /cypher-rs/users
Content-type: application/json
Body: [{"name":"Andres"},{"name":"Peter"},{"name":"NotExists"}]
!
--> 200
[{"name":"Andres","age":21,"children":["Cypher","L.","N."]},
{"name":"Peter" ,“age“:32,"children":["Neo4j","O.","K."]},
null]
POST - Write
POST Request - Write JSON
POST /cypher-rs/create-user
Content-type: application/json
Body: {"name":"Andres","age":21}
--> 201
POST Request - Write JSON (II)
POST /cypher-rs/create-user
Content-type: application/json
Body: [{"name":"Andres","age":21},
{"name":"Peter", "age":40},
--> 201
POST Request - Write CSV (III)
POST /cypher-rs/create-user[?batch=20000&delim=,]
Content-type: text/plain
Body: name,agenAndres,21nPeter,40
--> 201
More Management
Delete Endpoint
DELETE /cypher-rs/users
--> 200
List Endpoints
GET /cypher-rs
--> 200
[„create-users“, „users“]
Inspect Endpoint
GET /cypher-rs/users/query
--> 200
match (n:User) where n.name={name} return n
Results
Possible Results
single column, single row!
{"name":"Andres","age":21,"children":["Cypher","L.","N."]}
single column, multiple rows!
[
{"name":"Andres","age":21,"children":["Cypher","L.","N."]},
{"name":"Peter", "age":40,"children":["Neo4j","O.","K."]}
]
Possible Results (II)
multiple columns, single row!
{"user": "Andres", "friends": ["Peter","Michael"]}
multiple columns, multiple rows!
[
{"user": "Andres", "friends": ["Peter","Michael"]},
{"user": "Michael","friends": ["Peter","Andres"]},
{"user": "Peter", "friends": ["Andres","Michael"]}
]
Implementation
Implementation - Init
Implementation - PUT
Implementation - GET
Usage
Build with mvn clean install dependency:copy-dependencies
Copy files
cypher-rs-2.0-SNAPSHOT.jar opencsv-2.3.jar to path/to/server/plugins
Add this line to path/to/server/conf/neo4j-server.properties
org.neo4j.server.thirdparty_jaxrs_classes=org.neo4j.cypher_rs=/cypher-rs
Restart
Next Steps
• Add streaming
• Rule the world

Contenu connexe

Tendances

Hybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsHybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS Applications
Steven Francia
 
London HUG
London HUGLondon HUG
London HUG
Boudicca
 

Tendances (20)

Hybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsHybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS Applications
 
[PASS Summit 2016] Azure DocumentDB: A Deep Dive into Advanced Features
[PASS Summit 2016] Azure DocumentDB: A Deep Dive into Advanced Features[PASS Summit 2016] Azure DocumentDB: A Deep Dive into Advanced Features
[PASS Summit 2016] Azure DocumentDB: A Deep Dive into Advanced Features
 
Conceptos básicos. Seminario web 1: Introducción a NoSQL
Conceptos básicos. Seminario web 1: Introducción a NoSQLConceptos básicos. Seminario web 1: Introducción a NoSQL
Conceptos básicos. Seminario web 1: Introducción a NoSQL
 
Introducción a NoSQL
Introducción a NoSQLIntroducción a NoSQL
Introducción a NoSQL
 
London HUG
London HUGLondon HUG
London HUG
 
Conceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producciónConceptos básicos. Seminario web 6: Despliegue de producción
Conceptos básicos. Seminario web 6: Despliegue de producción
 
MongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl AppMongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl App
 
BDT204 Awesome Applications of Open Data - AWS re: Invent 2012
BDT204 Awesome Applications of Open Data - AWS re: Invent 2012BDT204 Awesome Applications of Open Data - AWS re: Invent 2012
BDT204 Awesome Applications of Open Data - AWS re: Invent 2012
 
Presentation: mongo db & elasticsearch & membase
Presentation: mongo db & elasticsearch & membasePresentation: mongo db & elasticsearch & membase
Presentation: mongo db & elasticsearch & membase
 
The Web of data and web data commons
The Web of data and web data commonsThe Web of data and web data commons
The Web of data and web data commons
 
Session5 04.evangelos varthis
Session5 04.evangelos varthisSession5 04.evangelos varthis
Session5 04.evangelos varthis
 
Introducing Azure DocumentDB - NoSQL, No Problem
Introducing Azure DocumentDB - NoSQL, No ProblemIntroducing Azure DocumentDB - NoSQL, No Problem
Introducing Azure DocumentDB - NoSQL, No Problem
 
Building a Directed Graph with MongoDB
Building a Directed Graph with MongoDBBuilding a Directed Graph with MongoDB
Building a Directed Graph with MongoDB
 
MongoDB as a fast and queryable cache
MongoDB as a fast and queryable cacheMongoDB as a fast and queryable cache
MongoDB as a fast and queryable cache
 
Azure DocumentDB: Advanced Features for Large Scale-Apps
Azure DocumentDB: Advanced Features for Large Scale-AppsAzure DocumentDB: Advanced Features for Large Scale-Apps
Azure DocumentDB: Advanced Features for Large Scale-Apps
 
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
 
HAProxyでMySQL HA on Amazon EC2
HAProxyでMySQL HA on Amazon EC2HAProxyでMySQL HA on Amazon EC2
HAProxyでMySQL HA on Amazon EC2
 
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...
 
First steps to Azure Cosmos DB: Getting Started with MongoDB and NoSQL
First steps to Azure Cosmos DB: Getting Started with MongoDB and NoSQLFirst steps to Azure Cosmos DB: Getting Started with MongoDB and NoSQL
First steps to Azure Cosmos DB: Getting Started with MongoDB and NoSQL
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 

Similaire à Document Oriented Access to Graphs

Sharing a Startup’s Big Data Lessons
Sharing a Startup’s Big Data LessonsSharing a Startup’s Big Data Lessons
Sharing a Startup’s Big Data Lessons
George Stathis
 
Drill Bay Area HUG 2012-09-19
Drill Bay Area HUG 2012-09-19Drill Bay Area HUG 2012-09-19
Drill Bay Area HUG 2012-09-19
jasonfrantz
 
ODSC East 2017 - Reproducible Research at Scale with Apache Zeppelin and Spark
ODSC East 2017 - Reproducible Research at Scale with Apache Zeppelin and SparkODSC East 2017 - Reproducible Research at Scale with Apache Zeppelin and Spark
ODSC East 2017 - Reproducible Research at Scale with Apache Zeppelin and Spark
Carolyn Duby
 
The openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageThe openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query Language
Neo4j
 

Similaire à Document Oriented Access to Graphs (20)

Relational to Graph - Import
Relational to Graph - ImportRelational to Graph - Import
Relational to Graph - Import
 
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'tsThe Fine Art of Schema Design in MongoDB: Dos and Don'ts
The Fine Art of Schema Design in MongoDB: Dos and Don'ts
 
Sharing a Startup’s Big Data Lessons
Sharing a Startup’s Big Data LessonsSharing a Startup’s Big Data Lessons
Sharing a Startup’s Big Data Lessons
 
Combine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quickl
 
Drill at the Chug 9-19-12
Drill at the Chug 9-19-12Drill at the Chug 9-19-12
Drill at the Chug 9-19-12
 
Drill Bay Area HUG 2012-09-19
Drill Bay Area HUG 2012-09-19Drill Bay Area HUG 2012-09-19
Drill Bay Area HUG 2012-09-19
 
Sep 2012 HUG: Apache Drill for Interactive Analysis
Sep 2012 HUG: Apache Drill for Interactive Analysis Sep 2012 HUG: Apache Drill for Interactive Analysis
Sep 2012 HUG: Apache Drill for Interactive Analysis
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_data
 
Xephon K A Time series database with multiple backends
Xephon K A Time series database with multiple backendsXephon K A Time series database with multiple backends
Xephon K A Time series database with multiple backends
 
Graph databases and the #panamapapers
Graph databases and the #panamapapersGraph databases and the #panamapapers
Graph databases and the #panamapapers
 
managing big data
managing big datamanaging big data
managing big data
 
Using Neo4j from Java
Using Neo4j from JavaUsing Neo4j from Java
Using Neo4j from Java
 
Analyzing Large-Scale User Data with Hadoop and HBase
Analyzing Large-Scale User Data with Hadoop and HBaseAnalyzing Large-Scale User Data with Hadoop and HBase
Analyzing Large-Scale User Data with Hadoop and HBase
 
Secure Streaming-as-a-Service with Kafka/Spark/Flink in Hopsworks
Secure Streaming-as-a-Service with Kafka/Spark/Flink in HopsworksSecure Streaming-as-a-Service with Kafka/Spark/Flink in Hopsworks
Secure Streaming-as-a-Service with Kafka/Spark/Flink in Hopsworks
 
Hopsworks Secure Streaming as-a-service with Kafka Flinkspark - Theofilos Kak...
Hopsworks Secure Streaming as-a-service with Kafka Flinkspark - Theofilos Kak...Hopsworks Secure Streaming as-a-service with Kafka Flinkspark - Theofilos Kak...
Hopsworks Secure Streaming as-a-service with Kafka Flinkspark - Theofilos Kak...
 
ODSC East 2017 - Reproducible Research at Scale with Apache Zeppelin and Spark
ODSC East 2017 - Reproducible Research at Scale with Apache Zeppelin and SparkODSC East 2017 - Reproducible Research at Scale with Apache Zeppelin and Spark
ODSC East 2017 - Reproducible Research at Scale with Apache Zeppelin and Spark
 
AgensGraph Presentation at PGConf.us 2017
AgensGraph Presentation at PGConf.us 2017AgensGraph Presentation at PGConf.us 2017
AgensGraph Presentation at PGConf.us 2017
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
 
The openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query LanguageThe openCypher Project - An Open Graph Query Language
The openCypher Project - An Open Graph Query Language
 
Big data workloads using Apache Sparkon HDInsight
Big data workloads using Apache Sparkon HDInsightBig data workloads using Apache Sparkon HDInsight
Big data workloads using Apache Sparkon HDInsight
 

Plus de Neo4j

Plus de Neo4j (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
QIAGEN: Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
QIAGEN: Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansQIAGEN: Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
QIAGEN: Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
ISDEFE - GraphSummit Madrid - ARETA: Aviation Real-Time Emissions Token Accre...
ISDEFE - GraphSummit Madrid - ARETA: Aviation Real-Time Emissions Token Accre...ISDEFE - GraphSummit Madrid - ARETA: Aviation Real-Time Emissions Token Accre...
ISDEFE - GraphSummit Madrid - ARETA: Aviation Real-Time Emissions Token Accre...
 
BBVA - GraphSummit Madrid - Caso de éxito en BBVA: Optimizando con grafos
BBVA - GraphSummit Madrid - Caso de éxito en BBVA: Optimizando con grafosBBVA - GraphSummit Madrid - Caso de éxito en BBVA: Optimizando con grafos
BBVA - GraphSummit Madrid - Caso de éxito en BBVA: Optimizando con grafos
 
Graph Everywhere - Josep Taruella - Por qué Graph Data Science en tus modelos...
Graph Everywhere - Josep Taruella - Por qué Graph Data Science en tus modelos...Graph Everywhere - Josep Taruella - Por qué Graph Data Science en tus modelos...
Graph Everywhere - Josep Taruella - Por qué Graph Data Science en tus modelos...
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Neo4j_Exploring the Impact of Graph Technology on Financial Services.pdf
Neo4j_Exploring the Impact of Graph Technology on Financial Services.pdfNeo4j_Exploring the Impact of Graph Technology on Financial Services.pdf
Neo4j_Exploring the Impact of Graph Technology on Financial Services.pdf
 
Rabobank_Exploring the Impact of Graph Technology on Financial Services.pdf
Rabobank_Exploring the Impact of Graph Technology on Financial Services.pdfRabobank_Exploring the Impact of Graph Technology on Financial Services.pdf
Rabobank_Exploring the Impact of Graph Technology on Financial Services.pdf
 
Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!Webinar - IA generativa e grafi Neo4j: RAG time!
Webinar - IA generativa e grafi Neo4j: RAG time!
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
Neo4j: Data Engineering for RAG (retrieval augmented generation)
Neo4j: Data Engineering for RAG (retrieval augmented generation)Neo4j: Data Engineering for RAG (retrieval augmented generation)
Neo4j: Data Engineering for RAG (retrieval augmented generation)
 
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdfNeo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
Neo4j Graph Summit 2024 Workshop - EMEA - Breda_and_Munchen.pdf
 
Enabling GenAI Breakthroughs with Knowledge Graphs
Enabling GenAI Breakthroughs with Knowledge GraphsEnabling GenAI Breakthroughs with Knowledge Graphs
Enabling GenAI Breakthroughs with Knowledge Graphs
 
Neo4j_Anurag Tandon_Product Vision and Roadmap.Benelux.pptx.pdf
Neo4j_Anurag Tandon_Product Vision and Roadmap.Benelux.pptx.pdfNeo4j_Anurag Tandon_Product Vision and Roadmap.Benelux.pptx.pdf
Neo4j_Anurag Tandon_Product Vision and Roadmap.Benelux.pptx.pdf
 
Neo4j Jesus Barrasa The Art of the Possible with Graph
Neo4j Jesus Barrasa The Art of the Possible with GraphNeo4j Jesus Barrasa The Art of the Possible with Graph
Neo4j Jesus Barrasa The Art of the Possible with Graph
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Document Oriented Access to Graphs

  • 1. Document oriented access to a graph database Using a Neo4j Server Extension Michael Hunger - @mesirii http://github.com/jexp/cypher-rs
  • 3. Graphs are great • for modeling highly connected domains • finding patterns to answer questions • high performance traversals
  • 5. Graphs suck • for compact access patterns • use-case specific views • easy integration in modern webapps
  • 8. Documents are great • for everything that eats JSON • especially modern JavaScript based webapps • as dedicated projections of a domain • compact representation
  • 9. Documents are great { name:"Michael", age:39, children:[„Selina“,“Rana“,"Selma"], address: { street: „Holbeinstr“, city: „Dresden“} hobbies: [„Coding“,„Buchbar“,“MUD MorgenGrauen“] blog: „http://jexp.de/blog“ }
  • 10. Documents suck • for different projections besides the main use-case • for connected data • for cross-document linking • for less redundancy / duplication
  • 11. Documents suck { name:"Michael", age:39, children:[„Selina“,“Rana“,"Selma"], address: { street: „Holbeinstr“, city: „Dresden“} hobbies: [„Coding“,„Buchbar“,“MUD MorgenGrauen“] blog: „http://jexp.de/blog“ } „Show people by hobby“
  • 12. Documents suck { _id: 1, name:“Michael“, works_at: dbref:2 } { _id: 2, name:“Neo Technology“, employees: [dbref:1] } „Link Employees to Companies“
  • 13. What can we do? • Use a document oriented access layer for a graph database • Use graph queries whose results project into documents • Make them easily accessible
  • 14. How can we do that? • Use Cypher in Neo4j 2.0 • Support for literal maps • Parameters, including maps
  • 16. Cypher & Maps - Results MATCH (n:User) WHERE n.name={name} RETURN n // returns a map of the node’s properties RETURN {id: id(n), labels: labels(n), data : n}
  • 17. Cypher & Maps - Results (II) MATCH (n:User)-[:PARENT_OF]->(child) WHERE n.name={name} RETURN {name:n.name, children:collect(child.name)}
  • 18. Cypher & Maps - Params CREATE (u:User { name: {p}.name, age: {p}.age}) RETURN u CREATE (u:User {params}) RETURN u
  • 20. How can we do that? • Create a RESTful API to • Provide endpoints that represent on Cypher queries • Use GET, POST with parameters to execute those endpoints • Return only JSON documents or lists of those
  • 21. How do we implement it? • Add a Neo4j-Server-Extension • Jersey JAX-RS • Save queries in graph properties • Execute queries for reads on GET • Execute queries for reads and writes on POST • Support JSON and CSV as payload • Batch transactional write operations
  • 22. What does it look like?
  • 23. What does it look like? • Examples for • Managing endpoints • Querying Endpoints • Writing to Endpoints
  • 24. Create Endpoint PUT /cypher-rs/users Body: match (n:User) where n.name={name} return n --> 201 Location: /cypher-rs/users PUT /cypher-rs/create-user Body: create (n:Node {name:{name},age:{age}}) --> 201 Location: /cypher-rs/create-user
  • 25. GET, POST - Reads
  • 26. GET Request GET /cypher-rs/users?name=Andres --> 200 {"name":"Andres", "age":21,"children":["Cypher","L.","N."]} GET /cypher-rs/users?name=NotExists --> 204
  • 27. POST Request - Read POST /cypher-rs/users Content-type: application/json Body: {"name":"Andres"} --> 200 {"name":"Andres","age":21, "children":["Cypher","L.","N."]}
  • 28. POST Request - Read (II) POST /cypher-rs/users Content-type: application/json Body: [{"name":"Andres"},{"name":"Peter"},{"name":"NotExists"}] ! --> 200 [{"name":"Andres","age":21,"children":["Cypher","L.","N."]}, {"name":"Peter" ,“age“:32,"children":["Neo4j","O.","K."]}, null]
  • 30. POST Request - Write JSON POST /cypher-rs/create-user Content-type: application/json Body: {"name":"Andres","age":21} --> 201
  • 31. POST Request - Write JSON (II) POST /cypher-rs/create-user Content-type: application/json Body: [{"name":"Andres","age":21}, {"name":"Peter", "age":40}, --> 201
  • 32. POST Request - Write CSV (III) POST /cypher-rs/create-user[?batch=20000&delim=,] Content-type: text/plain Body: name,agenAndres,21nPeter,40 --> 201
  • 35. List Endpoints GET /cypher-rs --> 200 [„create-users“, „users“]
  • 36. Inspect Endpoint GET /cypher-rs/users/query --> 200 match (n:User) where n.name={name} return n
  • 38. Possible Results single column, single row! {"name":"Andres","age":21,"children":["Cypher","L.","N."]} single column, multiple rows! [ {"name":"Andres","age":21,"children":["Cypher","L.","N."]}, {"name":"Peter", "age":40,"children":["Neo4j","O.","K."]} ]
  • 39. Possible Results (II) multiple columns, single row! {"user": "Andres", "friends": ["Peter","Michael"]} multiple columns, multiple rows! [ {"user": "Andres", "friends": ["Peter","Michael"]}, {"user": "Michael","friends": ["Peter","Andres"]}, {"user": "Peter", "friends": ["Andres","Michael"]} ]
  • 44. Usage Build with mvn clean install dependency:copy-dependencies Copy files cypher-rs-2.0-SNAPSHOT.jar opencsv-2.3.jar to path/to/server/plugins Add this line to path/to/server/conf/neo4j-server.properties org.neo4j.server.thirdparty_jaxrs_classes=org.neo4j.cypher_rs=/cypher-rs Restart
  • 45. Next Steps • Add streaming • Rule the world