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.
Den här övningen är en del av kursen
Graph RAG with LangChain and Neo4j
Övningsinstruktioner
- Complete the Cypher statement to find or create
PersonandCoursenodes withnameandtitleproperties, respectively, and joined by anENROLLED_INrelationship. - Query
graphusing your own name and with the course title provided.
Interaktiv övning med praktiskt arbete
Testa den här övningen genom att slutföra den här exempelkoden.
# 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'])