There are many ways to use Neo4j from Java. In this talk I want to demonstrate different APIs and examples on how to build solutions on top of Neo4j using a Java based stack.
8. Value from Data Relationships
Common Use Cases
Internal Applications
Master Data Management
Network and
IT Operations
Fraud Detection
Customer-Facing Applications
Real-Time Recommendations
Graph-Based Search
Identity and
Access Management
10. CAR
name: "Dan"
born: May 29, 1970
twitter: "@dan"
name: "Ann"
born: Dec 5, 1975
since:
Jan 10, 2011
brand: "Volvo"
model: "V70"
Property Graph Model
Nodes
• The objects in the graph
• Can have name-value properties
• Can be labeled
Relationships
• Relate nodes by type and direction
• Can have name-value properties
LOVES
LOVES
LIVES WITH
PERSON PERSON
11. Relational to Graph
Relational Graph
KNOWS
ANDREAS
TOBIAS
MICA
DELIA
Person FriendPerson-Friend
ANDREAS
DELIA
TOBIAS
MICA
12. Neo4j: All About Patterns
(:Person { name:"Dan"} ) -[:LOVES]-> (:Person { name:"Ann"} )
LOVES
Dan Ann
LABEL PROPERTY
NODE NODE
LABEL PROPERTY
13. Cypher: Find Patterns
MATCH (:Person { name:"Dan"} ) -[:LOVES]-> (love:Person) RETURN love
LOVES
Dan ?
LABEL
NODE NODE
LABEL PROPERTY ALIAS ALIAS
29. Scala (AnormCypher – Spark)
import org.anormcypher._
import org.apache.spark.graphx._
val dbConn = Neo4jREST("localhost", 7474, "/db/data/")
val q = """MATCH (p1:Page)-[:Link]->(p2)
RETURN id(p1) AS from, id(p2) AS to LIMIT 100000000"""
val r = Cypher(q).apply()(dbConn)
val links = sc.parallelize(r,100).map(
Edge(row[Int]("from").toLong,row[Int]("to").toLong, None))
links.count
32. Spring Data Neo4j
@NodeEntity
class Person {
@GraphId Long id;
String name;
@Relationship(type="LOVES") Person loved;
}
interface PersonRepository extends GraphRepository<Person> {
@Query("MATCH ... RETURN loved")
Set<Person> findLoved(String person)
}
Digital Asset Management System in 2000
SaaS many users in many countries
Two hard use-cases
Multi language keyword search
Including synonyms / word hierarchies
Access Management to Assets for SaaS Scale
Tried with many relational DBs
JOIN Performance Problems
Hierarchies, Networks, Graphs
Modeling Problems
Data Model evolution
No Success, even …
With expensive database consultants!
Graph Model & API sketched on a napkin
Nodes connected by Relationships
Just like your conceptual model
Implemented network-database in memory
Java API, fast Traversals
Worked well, but …
No persistence, No Transactions
Long import / export time from relational storage
Evolved to full fledged database in Java
With persistence using files + memory mapping
Transactions with Transaction Log (WAL)
Lucene for fast Node search
Founded Company in 2007
Neo4j (REST)-Server
Neo4j Clustering & HA
Cypher Query Language
Today …
Graphs are everywhere
people, events, locations
science, arts
politics, history
everything is connected there is no disconnected information
Presenter Notes - How does one take advantage of data relationships for real-time applications?
To take advantage of relationships
Data needs to be available as a network of connections (or as a graph)
Real-time access to relationship information should be available regardless of the size of data set or number and complexity of relationships
The graph should be able to accommodate new relationships or modify existing ones
Why ?
Because we can!
Java is really fast
Operations on GDS
Beans
Creating 100M Nodes, Relationships and Properties in 163s
Just an Jax-RS Resource
Configured in neo4j-server.properties
high performance operations
In the near future, many of your apps will be driven by data relationships and not transactions
You can unlock value from business relationships with Neo4j