The MERGE clause
The MERGE
clause will find or create a pattern in the database. It is good practice to split your MERGE
statements into one clause per node or relationship.
Time to try out a MERGE
query on your Neo4j database, graph
.
Este exercício faz parte do curso
Graph RAG with LangChain and Neo4j
Instruções do exercício
- Complete the Cypher statement to find or create
Person
andCourse
nodes withname
andtitle
properties, respectively, and joined by anENROLLED_IN
relationship. - Query
graph
using your own name and with the course title provided.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Modify the your Cypher statement
cypher = """
____ (p:____ {name: $name})
____ (c:____ {title: $title})
MERGE (p)-[:ENROLLED_IN]->(c)
RETURN p.name AS name
"""
# Add your name to the query
result = graph.query(cypher,
{"name": "____", "title": "Graph RAG with LangChain and Neo4j"}
)
for record in result:
print(record['name'])