webinar: what's new in neo4j 2.0
DESCRIPTION
TRANSCRIPT
![Page 1: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/1.jpg)
WebinarAug 8 2013
What‘s new in Neo4j 2.0Michael Hunger, Neo Technology
@mesirii | @neo4j
![Page 2: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/2.jpg)
BIG NEWS
Neo4j 2.0.0-M04 released today!
![Page 3: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/3.jpg)
Neo4j 2.0
![Page 4: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/4.jpg)
Why 2.0?
![Page 5: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/5.jpg)
(0.x) --> (1.x) --> (2.x)
• 0.x was about embedded java
• 1.x introduced indexes, the server and REST
• 2.x ease of use, big data, cloud
which means a focus on...
![Page 6: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/6.jpg)
This guy
![Page 7: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/7.jpg)
Focus on Cypher
• Cypher, a carefully crafted language for working with graphs
• Declarative, friendly, easy to read and write
• One language, used everywhere
• REST for management, Java for extensions
![Page 8: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/8.jpg)
What is new in 2.0?
![Page 9: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/9.jpg)
Introducing: Node Labels
![Page 10: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/10.jpg)
WORKS_WITH
Person
Employee
Developer
Husband
NoSQL
GraphDB
Database
Awesome!
No Schema is goodSome Structure is helpful
![Page 11: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/11.jpg)
• Simply: a label identifies a set of nodes
• Nodes can have multiple labels
• Find nodes by label
• Constrain properties and values
(lightweight, optional schema)
• A simple idea, with powerful applications
Introducing Node Labels
NoSQL
GraphDB
Database
Awesome!
![Page 12: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/12.jpg)
How to use labels?
![Page 13: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/13.jpg)
Labels - how to use?• To identify nodes
• To categorize, tag
• To represent types
• To avoid confusion
• For special nodes (domain specific reference nodes)
![Page 14: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/14.jpg)
Labels - rules of thumb• Use a label to make queries easier to read & write
• And to improve performance through indexing
• Start with anything you might've put in a legacy index
• Use lightly, as few labels as needed
![Page 15: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/15.jpg)
Find friends who like cheese
MATCH (p:Person)-[:FRIENDS]->(friend:Person),
(friend) -[:LIKE]-> (thing:Thing)
WHERE p.name = "Max De Marzi"
AND thing:Food AND thing.name = "Cheese"
RETURN thing, labels(thing);
![Page 16: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/16.jpg)
Schema Indexing• Indexes for labels, based on a property
• Simple lookups for now
• Unique indexing coming soon
• Full-text, other special indexes in planningCREATE INDEX ON :Person(name)MATCH (p:Person)WHERE p.name = „Max“RETURN p
![Page 17: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/17.jpg)
MERGE operation• a combination of MATCH + CREATE
• replaces CREATE UNIQUE (currently still limited)
• attempts to MATCH, with specified properties and labels
• if match fails, new graph data is created
• optional sub-clauses for handling ON CREATE, and ON MATCHMERGE (p:Person { name:'Charlie Sheen', age:10 })ON CREATE p SET p.created = timestamp()RETURN p
![Page 18: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/18.jpg)
Hands-On Cypher
• Migrate Cineasts dataset to use Labels
• Show MATCH on Labels and Properties (+ profile)
• Add an Index on :Person(name) :Movie(title)
• Show MATCH on Labels and Properties (+ profile)
• Show MERGE with a user
https://gist.github.com/jexp/6193139#file-setup-start-shhttps://gist.github.com/jexp/6193139#file-upgrade-movie-database-to-2-0-cql
![Page 19: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/19.jpg)
Demo
![Page 20: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/20.jpg)
Anything else?
• Breaking changes to some APIs (read CHANGES.txt)
• Migration of "legacy" indexes (stop STARTing)
• Mandatory transactions for all DB interactions
• Improving installers (in progress)
• Changing everything to be "all Cypher, all the time"
![Page 21: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/21.jpg)
Cypher Changes: Properties • no schema -> what happens when properties don‘t exist
• has(n.prop) AND n.prop=“Foobar“
• there was syntactic sugar n.prop! and n.prop?
• now n.prop returns NULL covers n.prop! =“Foobar“
• explicit expression for n.prop? = „Foobar“
WHERE n.name = „Chris“AND (not(m.name) OR m.name=“Andres“)
![Page 22: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/22.jpg)
Cypher Changes: REMOVE • consistent remove operations of labels and properties
• you REMOVE attributes (properties, labels)
• and DELETE elements (nodes, relationships)
REMOVE n.nameREMOVE n:People
DELETE nodeDELETE relationship
![Page 23: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/23.jpg)
Cypher Changes: Separators • grammar has to be unambiguous
• extract(n in nodes:Foo)???
• confuse colon from label and collection function separator
• exchanged colon for pipe
EXTRACT (n in nodes | n.name)FILTER (n in nodes | n.name =~ „And.*“)FOREACH (v in names | CREATE ( {name: v} ))
![Page 24: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/24.jpg)
Demo
![Page 25: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/25.jpg)
Mandatory Transactions• we had optional transactions for reads
• Issues:
• In which context do I read?
• Do I read what I read?
• Which changes do I see?
• NOW: Mandatory Transactions for reads and writes!
• only affects embedded API
• Cypher and REST-API take care of their transactions
![Page 26: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/26.jpg)
• begin, commit, or rollback a transaction
• transaction as RESTful resource
• issue multiple statements per request
• multiple requests per transaction
• compact response format
• some driver already support it (neography, jdbc)
Transactional Cypher
![Page 27: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/27.jpg)
Hands-On 2.0• Show Transactional HTTP-Endpoint
• POST initial statements, look at result, check currently running tx in server-info
• POST another create statement to the tx
• POST a new read statement to a new tx that shows isolation
• DELETE second transaction
• POST to COMMIT resourcehttps://gist.github.com/jexp/6193139#file-demo-transactional-endpoint-js
![Page 28: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/28.jpg)
What is new in 2.0?
• It's all about Cypher, starting with
• Labels, the first significant change in over 12 years
• Mix in schema indexing
• Then transactional REST, new clauses, functions
• A fresh Web UI that is Cypher-focused
![Page 29: Webinar: What's new in Neo4j 2.0](https://reader033.vdocuments.net/reader033/viewer/2022042813/54b701ff4a7959aa2a8b4713/html5/thumbnails/29.jpg)
Thanks :)
MATCH (you)-[:HAVE]->(q:Question)RETURN q.text
@neo4j or @mesirii to keep in touch