OpenCypher Subset Specification
Cross-backend Cypher compatibility reference for Neo4j, Amazon Neptune, and Memgraph.
Queries composed exclusively of the clauses and functions listed below are
guaranteed to execute identically on all three backends without dialect
translation . Vendor-specific operations that fall outside this subset are
handled by the dialect translators in src/core/dialect_translators.py.
Requirements : 8.1, 8.2, 8.5
Supported Clauses
Clause
Syntax
Notes
MATCH
MATCH (n:Label)-[r:TYPE]->(m)
Core pattern matching
OPTIONAL MATCH
OPTIONAL MATCH (n)-[r]->(m)
Left-outer-join semantics
CREATE
CREATE (n:Label {key: value})
Node and relationship creation
MERGE
MERGE (n:Label {key: value})
Upsert semantics
ON CREATE SET
MERGE ... ON CREATE SET n.x = 1
Set properties on creation
ON MATCH SET
MERGE ... ON MATCH SET n.x = 2
Set properties on match
DELETE
DELETE n
Delete nodes (must have no relationships)
DETACH DELETE
DETACH DELETE n
Delete nodes and their relationships
SET
SET n.key = value
Property assignment
REMOVE
REMOVE n.key / REMOVE n:Label
Property or label removal
RETURN
RETURN n, n.name AS name
Result projection
WITH
WITH n, count(*) AS cnt
Intermediate projection / aggregation
WHERE
WHERE n.age > 30
Predicate filtering
ORDER BY
ORDER BY n.name ASC
Result ordering (ASC / DESC)
LIMIT
LIMIT 10
Cap result count
SKIP
SKIP 5
Offset results
UNWIND
UNWIND $list AS item
Expand a list into rows
CASE
CASE WHEN ... THEN ... ELSE ... END
Conditional expressions
Supported Functions
Aggregation Functions
Function
Description
count(expr)
Count non-null values (or count(*) for all rows)
sum(expr)
Sum of numeric values
avg(expr)
Average of numeric values
min(expr)
Minimum value
max(expr)
Maximum value
collect(expr)
Collect values into a list
Scalar Functions
Function
Description
size(list)
Number of elements in a list or length of a string
length(path)
Length of a path (number of relationships)
type(r)
Relationship type as a string
labels(n)
List of labels on a node
keys(n)
List of property keys on a node or relationship
properties(n)
Map of all properties on a node or relationship
id(n)
Internal integer ID of a node or relationship
coalesce(a, b, ...)
First non-null argument
String Functions
Function
Description
toString(expr)
Convert value to string
toLower(str)
Lowercase string
toUpper(str)
Uppercase string
trim(str)
Remove leading and trailing whitespace
replace(str, search, replacement)
Replace all occurrences
substring(str, start [, length])
Extract substring
split(str, delimiter)
Split string into list
Type Conversion Functions
Function
Description
toInteger(expr)
Convert to integer
toFloat(expr)
Convert to float
List Functions
Function
Description
head(list)
First element of a list
tail(list)
All elements except the first
last(list)
Last element of a list
range(start, end [, step])
Generate integer list
reverse(list)
Reverse a list
Math Functions
Function
Description
abs(expr)
Absolute value
ceil(expr)
Round up to nearest integer
floor(expr)
Round down to nearest integer
round(expr)
Round to nearest integer
sqrt(expr)
Square root
Vendor-Specific Operations (Require Dialect Translation)
The following operations are not part of the OpenCypher subset and must be
routed through the appropriate dialect translator (NeptuneCypherTranslator,
MemgraphCypherTranslator) before execution.
Vector Search
Backend
Procedure / API
Neo4j
CALL db.index.vector.queryNodes(indexName, topK, queryVector)
Neptune
Neptune Analytics neptune.algo.vectors.topK.byEmbedding via execute_query API
Memgraph
CALL vector_search.search(indexName, topK, queryVector)
Fulltext Search
Backend
Procedure / API
Neo4j
CALL db.index.fulltext.queryNodes(indexName, queryText)
Neptune
OpenSearch companion service (multi_match query)
Memgraph
Cypher CONTAINS / toLower fallback (no native fulltext index)
Schema Introspection
Backend
Command
Neo4j
CALL db.labels(), CALL db.relationshipTypes()
Neptune
GetGraphSummary API (Neptune Analytics) or MATCH-based discovery
Memgraph
CALL schema.node_type_properties(), CALL schema.rel_type_properties()
Graph Algorithms
Backend
Library / API
Neo4j
APOC / GDS procedures
Neptune
Neptune Analytics algorithm procedures (neptune.algo.*)
Memgraph
MAGE library procedures (pagerank.get, community_detection.get, etc.)
elementId() Function
Backend
Behavior
Neo4j
Returns a string element identifier (Neo4j 5+)
Neptune
Not supported — translated to id() by NeptuneCypherTranslator
Memgraph
Not supported — translated to id() by MemgraphCypherTranslator
APOC Collection Functions
Function
Translation
apoc.coll.toSet(list)
Python-side list(set(...))
apoc.coll.flatten(list)
Python-side itertools.chain.from_iterable(...)
apoc.convert.fromJsonList(str)
Python-side json.loads(...)
Administrative Commands
Command
Neo4j
Neptune
Memgraph
SHOW DATABASES
Supported
No-op (translated)
No-op (translated)
CALL db.awaitIndexes()
Supported
No-op (translated)
No-op (translated)
Known Behavioral Differences Across Backends
Even within the OpenCypher subset, there are minor behavioral differences to
be aware of:
id() Return Values
Neo4j : Returns a long integer. Stable within a transaction but may be
reused after node deletion.
Neptune : Returns a string identifier. Globally unique and stable.
Memgraph : Returns a long integer. Stable and not reused.
labels() Ordering
Neo4j : Returns labels in the order they were added.
Neptune : Label ordering is not guaranteed.
Memgraph : Label ordering is not guaranteed.
NULL Handling in Aggregations
All three backends follow the OpenCypher specification: NULL values are
excluded from count(expr), sum(), avg(), min(), and max().
count(*) counts all rows including those with NULL values.
Property Type Coercion
Neo4j : Strict typing — setting a property to a different type replaces it.
Neptune : Supports heterogeneous property values on different nodes with
the same key.
Memgraph : Strict typing similar to Neo4j.
MERGE Locking Behavior
Neo4j : Uses internal locks to prevent concurrent MERGE from creating
duplicates.
Neptune : Eventual consistency may allow duplicate creation under high
concurrency. Use application-level deduplication when needed.
Memgraph : Uses internal locks similar to Neo4j.
ORDER BY Stability
Neo4j : Stable sort (equal elements retain their relative order).
Neptune : Sort stability is not guaranteed.
Memgraph : Sort stability is not guaranteed.
Path Length with length()
All three backends return the number of relationships in a path when using
length(path). For string length, use size(str) instead — length() on
strings is deprecated in Neo4j 5+ but still works on all three backends.