LoslegenKostenlos loslegen

Running Cypher statements

You've been provided with a graph populated with people and companies. The graph schema has been printed for you, showing nodes of type Person and Company, and a relationship named WORKS_FOR between these two node types.

A Cypher statement that finds the (:Person) node with the name property equal to the $name parameter and returns the name property of the company they work for has been provided as cypher.

Execute the Cypher statement on graph to find out where Jo Cornelissen works.

Diese Übung ist Teil des Kurses

Graph RAG with LangChain and Neo4j

Kurs anzeigen

Anleitung zur Übung

  • Execute the Cypher statement stored in the cypher variable on graph.
  • Extract the 'company' from each result to return the matched companies.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

cypher = """MATCH (p:Person {name: $name})-[:WORKS_FOR]->(c:Company)
RETURN c.name AS company"""

# Execute the Cypher statement
result = graph.____(____, {"name": "Jo Cornelissen"})

# Extract the company 
for row in result:
    print(row[____])
Code bearbeiten und ausführen