The OPTIONAL MATCH clause is used to look for the sample described in it, while the use of nulls for lacking components of the sample.
OPTIONAL MATCH is similar to the suit clause, the handiest difference being it returns null due to the missing components of the pattern.
Syntax
Following is the syntax of the OPTIONAL MATCH with courting.
MATCH (node:label {properties. . . . . . . . . . . . . .})
OPTIONAL MATCH (node)-->(x)
RETURN x
Example
Following is a pattern Cypher Query which attempts to retrieve the family members from the node ICCT2013. Since there are not any such nodes, it returns null.
MATCH (a:Tornament {name: "ICC Champions Trophy 2013"})
OPTIONAL MATCH (a)-->(x)
RETURN x
To execute the above question, perform the following steps −
Step 1 − Open the Neo4j computing device App and begin the Neo4j Server. Open the built-in browser app of Neo4j the use of the URL http://localhost:7474/ as proven within the following screenshot.
Step 2 − Copy and paste the desired question inside the greenback set off and press the play button (to execute the question) highlighted inside the following screenshot.
Result
On executing, you will get the following result. Here you could study that considering that there are no fits for the desired sample, Neo4j returned null.