
Neo4j 2.0.0-RC1 – Final preparations
Cypher Syntax – finishing touches
MATCH with properties
CREATE
and
MERGE
clauses can have patterns with properties in them, but that syntax wasn’t previously supported in the
MATCH
clause. Now you can include properties in any pattern. This makes simple queries more concise; a query like this:
MATCH (a:Person) WHERE a.name = “Joe” RETURN a
MATCH (a:Person {name:”Joe”}) RETURN a
OPTIONAL MATCH
-[?]->
syntax. However, this sometimes proved confusing. To resolve the ambiguity,
Stefan Plantikow
came up with an excellent solution: separate the concerns.
MATCH
is now required, so the
?
operator has been removed. For optional patterns, use the new
OPTIONAL MATCH
, which either returns matching data, or
null
if nothing is found.
MATCH (a:Person)
OPTIONAL MATCH (a)-[:SPOUSE]->(b)
RETURN a, b
null
. Lovely!
MERGE for relationships
MERGE
for single nodes or
MERGE
for relationships (but not both at the same time).
MERGE
for relationships replaces the old
CREATE UNIQUE
clause.
MATCH (a:Person {name: “Joe”}), (b:Person {name: “Steve”})
MERGE (a)-[r:KNOWS]->(b)
RETURN r
Simpler syntax for MERGE ON MATCH and ON CREATE
MERGE
clause in your query, there are two possible outcomes: Neo4j will either find all existing matching data, or create entirely new data. The special sub-clauses
ON MATCH
and
ON CREATE
allow to you to distinguish between these outcomes.
ON MATCH
and
ON CREATE
clauses, removing the need to cite an identifier from the related
MERGE
pattern. Where you used to write:
MERGE (a:Person {name: “Joe”}) ON CREATE a SET a.created = {}
ON CREATE
):
MERGE (a:Person {name: “Joe”}) ON CREATE SET a.created = {}
NULL != NULL
null
in important ways: Many expressions now return
null
for invalid arguments (
HEAD([])
, Slicing, e.g.
[][1..3]
). We’ve embraced
ternary logic
by allowing
null
to be used as a “maybe” value in expressions with
AND
,
OR
,
NOT
meaning it’s easier to compute predicates when information (like property values) is missing.
working with null
.
Caution: manual upgrade between milestones
Data stores created with any previous milestone version can not be used with 2.0.0-RC1 unless a manual upgrade is performed
. This is due to incompatible changes made to the store files. Please proceed with caution, backing up your data before attempting to manually upgrade.
|
To be clear:
DO NOT USE THIS RELEASE WITH EXISTING DATA
Of course, as always you can safely upgrade between GA versions like 1.9.5 and the coming 2.0.0.
Breaking changes
-
textual status codes, which alter the error response from the transactional endpoint
-
clean-up of deprecated APIs
-
removal of reference node (
use labels instead
)
2.0.0.RC1 changelogs
.
Next steps
google group
and asking questions on
Stack Overflow
.
Andreas, on behalf of Team Neo
Want to learn more about graph databases? Click below to get your free copy of O’Reilly’s Graph Databases ebook and discover how to use graph technologies for your application today.