Cypher MATCH로 패턴 일치시키기
그래프 데이터에서 특정 노드 및 관계 패턴을 찾는 MATCH 절을 익힙니다.
Cypher MATCH로 패턴 일치시키기은(는) CoddyKit의 무료 Neo4j Graph Database Fundamentals 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Neo4j Graph Database Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Neo4j Graph Database Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Discovering Data with MATCH
Welcome to the core of graph querying! The MATCH clause in Cypher is how you find specific patterns of data in your Neo4j graph.
Think of it like drawing the shape of the data you want to find. You describe nodes, relationships, and their properties, and Neo4j finds all instances that fit your description.
Finding Any Node
The simplest MATCH query finds any node in your graph. You represent a node using parentheses ().
Adding a variable inside, like (n), lets you refer to that node later, for example, to return its properties. We'll use LIMIT to show just a few results.
MATCH (n)
RETURN n LIMIT 3Matching Nodes by Label
Graphs often have different types of nodes. In Cypher, these types are called labels. You can specify a label to find only nodes of a particular type.
Labels are placed after the node variable, separated by a colon: (variable:Label).
MATCH (p:Person)
RETURN p.name LIMIT 3Matching Nodes by Property
Nodes also have properties, which are key-value pairs describing them. You can filter nodes based on these properties directly within your MATCH clause.
Properties are placed inside curly braces {} after the label (or variable if no label): (node:Label {key: 'value'}).
MATCH (m:Movie {title: 'The Matrix'})
RETURN m.releaseYearIntroducing Relationships
Relationships define how nodes are connected. In MATCH, you represent a relationship using dashes and angle brackets: -- for undirected, --> for directed, and <-- for reverse directed.
You can also assign a variable to the relationship, like -[r]-, to work with it.
MATCH (a)-[r]->(b)
RETURN a.name, TYPE(r), b.title LIMIT 3Matching Relationships by Type
Just like nodes have labels, relationships have types. Specifying a relationship type helps you find specific kinds of connections between nodes.
The type is placed after the relationship variable, separated by a colon: -[r:TYPE]->.
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
RETURN p.name, m.title LIMIT 3Matching with Direction
Relationships are directional! The arrows in your MATCH pattern indicate the flow. If you omit arrows (e.g., (a)-[r]-(b)), the match will be undirected, finding connections regardless of their stored direction.
It's generally best practice to specify direction when you know it.
MATCH (director:Person)<-[:DIRECTED]-(movie:Movie)
RETURN director.name, movie.title LIMIT 3Combining Node & Relationship Patterns
The real power of MATCH comes from combining nodes and relationships to describe complex patterns in your graph. You can chain multiple nodes and relationships together.
This allows you to find paths, connections through intermediate nodes, and more.
MATCH (p:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(m:Movie)<-[:DIRECTED]-(d:Person)
RETURN p.name, m.title, d.nameFinding Optional Connections
Sometimes, a part of your pattern might not always exist. OPTIONAL MATCH tries to find the pattern, but if it doesn't, the unmatched parts will be null instead of failing the whole query.
This is useful when you want to see existing connections while still returning the main node even if a specific connection is missing.
MATCH (p:Person {name: 'Keanu Reeves'})
OPTIONAL MATCH (p)-[r]->(m:Movie)
RETURN p.name, TYPE(r), m.titleMatch Clause Challenge
Which Cypher MATCH clause correctly finds all movies directed by 'Quentin Tarantino'?
Recap: Mastering MATCH
Great job! You've learned the fundamental skill of finding patterns in your graph using the MATCH clause.
- Use
()for nodes,--for relationships. - Specify labels (
:Label) for node types and types (:TYPE) for relationships. - Filter by properties using
{}. - Arrows (
-->,<--) define relationship direction. OPTIONAL MATCHhelps find patterns that might not always exist without breaking the query.
Next, we'll explore how to refine your matched data using WHERE and ORDER BY!
자주 묻는 질문
“Cypher MATCH로 패턴 일치시키기” 강의는 무료인가요?
네 — “Cypher MATCH로 패턴 일치시키기” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Neo4j Graph Database Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Neo4j Graph Database Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.
“Cypher MATCH로 패턴 일치시키기”에서 뭘 배우나요?
그래프 데이터에서 특정 노드 및 관계 패턴을 찾는 MATCH 절을 익힙니다. 브라우저에서 직접 실행하는 실습 코드로 Neo4j Graph Database Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Neo4j Graph Database Fundamentals을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Neo4j Graph Database Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“Cypher MATCH로 패턴 일치시키기” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Neo4j Graph Database Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Neo4j Graph Database Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 노드, 관계 및 속성
- Cypher CREATE로 데이터 생성
- Cypher MATCH로 패턴 일치시키기
- RETURN으로 결과 반환하고 구성하기