Cypher vs GQL Syntax¶
Both Cypher and GQL are supported in Grafeo. This page documents the syntax differences for users who want to understand both or switch between them.
Creating Nodes¶
Tip
GQL's INSERT doesn't require a RETURN clause for simple creates.
Creating Relationships¶
Identical Syntax¶
Many features are identical in both languages:
-- Works in both Cypher and GQL
MATCH (p:Person)
WHERE p.age > 25
RETURN p.name, p.age
ORDER BY p.age DESC
LIMIT 10
Pattern Matching¶
-- Same in both
MATCH (a:Person)-[:KNOWS]->(b:Person)-[:KNOWS]->(c:Person)
WHERE a <> c
RETURN a.name, c.name
Variable-Length Paths¶
The syntax is identical for variable-length paths.
Function Differences¶
| Cypher | GQL | Description |
|---|---|---|
id(n) | id(n) | Internal node ID |
type(r) | type(r) | Relationship type |
labels(n) | labels(n) | Node labels |
toUpper(s) | upper(s) | Uppercase string |
toLower(s) | lower(s) | Lowercase string |
size(list) | length(list) | List length |
UNWIND vs FOR¶
Summary¶
| Feature | Cypher | GQL |
|---|---|---|
| Create nodes | CREATE | INSERT |
| Pattern matching | MATCH | MATCH |
| Filtering | WHERE | WHERE |
| Iteration | UNWIND | FOR |
| Everything else | Mostly identical | Mostly identical |