Cypher is a declarative graph query language associated with Neo4j. It queries connected data by matching nodes and relationships, making graph databases useful for knowledge-intensive applications where relationships, inference, and explainability matter. section 10.5
Unlike RDF-based systems that use triples and SPARQL, some graph databases use proprietary representations and query languages such as Cypher or Gremlin. LLMs can generate Cypher from natural-language questions when prompts constrain generation to the supplied schema. section 10.5
A schema-constrained query
A generated query can match a movie by title, follow incoming ACTED_IN relationships, and return the actor count: MATCH (m:Movie {title:"Top Gun"})<-[:ACTED_IN]-() RETURN count(*) AS numberOfActors. A generation template can require only supplied relationship types and properties and return no explanatory text. section 10.5
Practical use in retrieval systems includes:
- Convert natural-language questions into Cypher statements for graph retrieval. section 10.5
- Route graph-oriented questions to a graph retriever, alongside vector-store and SQL sources. section 10.8
- Test routing accuracy and add fallback logic when the primary source returns no results. section 10.8
Figure 10.4 Graph representation of data. Nodes represent entities such as Roberto and InterMilan, while edges such as hasOccupation and isFanOf depict their relationships.
Use the graph representation to inspect how entities become nodes and relationships become edges before writing or generating Cypher. section 10.5



