MATCH is the Cypher clause for finding graph patterns already stored in a database. Write the node and relationship pattern you want; Cypher’s declarative query engine determines how to retrieve matching data and binds the matched elements to variables for later clauses. section 3.1.2 section 3.4
Find a person by label and property
Match a labeled node inline, then return its bound variable. Inline properties make a compact pattern description; a WHERE clause can express the same label and property conditions. Combining an inline label with WHERE filters is a readable way to add conditions and alias output columns. section 3.1.2
Listing 3.6 Cypher statement that searches and retrieves any nodes with a label Person and a name property with a value of Satish
MATCH (p:Person {name:'Satish'})
RETURN p
This minimal query matches the Person node whose name is Satish and returns the variable p. section 3.1.2
Use MATCH as the selection step before other work:
- Chain MATCH clauses to find separate patterns. Each WHERE applies only to the MATCH immediately before it. section 3.1.2
- Use MATCH before DELETE to select the relationship or node that should be removed. Omitting a relationship type matches relationships of any type between the described nodes. section 3.1.6
- Match existing CSV-identified nodes before MERGE creates imported relationships. If a required pattern is absent, processing for that row does not continue. section 3.2.5
- Use OPTIONAL MATCH when a missing pattern should not discard other variables and rows from the result. section 3.1.2 section 3.4
- Match a two-hashtag pattern in a tweet, then count and rank the pairs to examine co-occurrence; constrain node IDs to remove mirrored duplicates. section 7.2
A regular MATCH is required: if it finds no specified pattern, the statement returns no results. This matters when matching several patterns, because one missing required match prevents a combined result. OPTIONAL MATCH preserves the available part of a query instead. section 3.1.2 section 3.4
