webinar: what's new in neo4j 2.0

Post on 15-Jan-2015

1.907 Views

Category:

Business

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

WebinarAug 8 2013

What‘s new in Neo4j 2.0Michael Hunger, Neo Technology

@mesirii | @neo4j

BIG NEWS

Neo4j 2.0.0-M04 released today!

Neo4j 2.0

Why 2.0?

(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...

This guy

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

What is new in 2.0?

Introducing: Node Labels

WORKS_WITH

Person

Employee

Developer

Husband

NoSQL

GraphDB

Database

Awesome!

No Schema is goodSome Structure is helpful

• 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!

How to use labels?

Labels - how to use?• To identify nodes

• To categorize, tag

• To represent types

• To avoid confusion

• For special nodes (domain specific reference nodes)

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

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);

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

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

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

Demo

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"

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“)

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

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} ))

Demo

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

• 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

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

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

Thanks :)

MATCH (you)-[:HAVE]->(q:Question)RETURN q.text

@neo4j or @mesirii to keep in touch

top related