>_TheQuery
← Glossary

Cypher

Knowledge Graphs

A declarative graph query language created for Neo4j that uses ASCII-art syntax to represent and match graph patterns.

Cypher is the query language for Neo4j graph databases, designed to be both human-readable and expressive for graph pattern matching. Its distinctive ASCII-art syntax uses parentheses for nodes and square brackets with arrows for relationships: (alice:Person)-[:WORKS_FOR]->(company:Company) visually represents a graph pattern.

Cypher supports the full range of graph operations: creating and matching patterns (MATCH, CREATE, MERGE), filtering results (WHERE), returning data (RETURN), aggregation (COUNT, SUM, AVG), path operations (shortestPath, variable-length patterns like [*1..3]), and graph algorithms via the GDS library (PageRank, community detection, Dijkstra's shortest path).

In hybrid RAG+KG systems, Cypher is often generated automatically from natural language queries using LLMs (text-to-Cypher). This enables users to query the knowledge graph without learning Cypher syntax. Production implementations include query validation (preventing destructive operations like DELETE), self-correction (retrying with error context when generated Cypher fails), and caching of common query patterns.

Last updated: February 22, 2026