In this post we will be covering how to shutdown neo4j service gracefully under different versions of neo4j. Continue reading “Shutdown Neo4j Gracefully”
Category: neo4j
Neo4J 2 – Understanding Collections
In Cypher, to fetch a Person with their email addresses and phone numbers, you might write a straight forward query like this:
MATCH (person:Person)
MATCH person-[:HAS_EMAIL]->email
MATCH person-[:HAS_PHONE]->phone
RETURN person,
collect(distinct email),
collect(distinct phone)
In this article, we will try to get a better understanding of collections in Cypher. At first, we will look under the hood to see how this query is run, understand why it is an expensive job and finally, how we can optimise it and avoid this undesired behaviour in the future.
Neo4J 2 – Joins in Cypher
The OPTIONAL MATCH clause is a way of fetching related data off a node, without affecting the main query. It allows us to perform some joins similar to the ones we know from SQL, see image below. We will discuss in detail how MATCH and OPTIONAL MATCH clauses can lend themselves towards constructing the joins.
Note: We will not be covering right joins as they are costly to perform in graph database, it is much more efficient to swap the sides and perform a flavour of left join. We also are not going to talk about Self Join.
Neo4J 2 – Basics of MATCH clause
In Cypher, a pattern for a MATCH clause consists of three parts as you can see in the image below.