Migrate from APOC to Cypher
Many APOC procedures and functions have full or partial equivalents in Cypher. Where a full Cypher equivalent exists, the corresponding APOC procedure or function is deprecated in the Cypher version that introduces the new Cypher feature, and will be removed in a future release.
Moving from APOC to Cypher has several benefits:
-
Seamless syntax: Write everything in one language, with no context switching between Cypher and procedure calls.
-
Planner and runtime optimizations: The query planner can see and optimize native Cypher, whereas procedure calls are opaque to it.
-
Static analysis and type checking: The planner can validate native Cypher, including types where they can be inferred, before the query runs.
-
Lower overhead: Native Cypher runs inside the query engine, so there is no overhead from calling a procedure and passing data in and out of it.
-
Simpler security: Native Cypher avoids the sandboxing and permission configuration that procedures require.
-
Ongoing improvements: Native Cypher features benefit from continued improvements to Neo4j and from the testing that comes with being part of the core language.
APOC functions and procedures not listed here have no native Cypher equivalent yet. Check this page when you upgrade, as procedures that are missing today may be covered later.
|
The equivalences listed here are relevant to Cypher 25. For more information about APOC, Neo4j, and Cypher versions, see the APOC and Cypher versions page. |
Conditionals (apoc)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s conditional queries
apoc.case
|
||
|
Cypher’s conditional queries
apoc.when
|
Aggregations (apoc.agg)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
Cypher’s
CALL subquery
apoc.agg.first
|
|||
|
Cypher’s
COLLECT {}
apoc.agg.graph
|
||
Cypher’s
CALL subquery
apoc.agg.last
|
|||
Cypher’s
COLLECT {} + CASE expression
apoc.agg.median
|
|||
Cypher’s
OFFSET and LIMIT
apoc.agg.nth
|
|||
|
Cypher’s
reduce
apoc.agg.product
|
||
Cypher’s
COLLECT {}
apoc.agg.slice
|
Algorithms (apoc.algo)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s
IN predicate
apoc.algo.cover
|
Property access (apoc.any)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
Cypher’s
properties function
apoc.any.properties
|
Cypher equivalent does not work on all runtimes for virtual nodes. |
||
Cypher’s property access operator
apoc.any.property
|
Cypher’s equivalent does not work on all runtimes for virtual nodes. |
Collections (apoc.coll)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s
IN predicate
apoc.coll.contains
|
||
|
Cypher’s
all
apoc.coll.containsAll
|
||
|
Cypher’s list comprehension
apoc.coll.fill
|
||
|
Cypher’s
coll.flatten
apoc.coll.flatten
|
||
|
Cypher’s
coll.indexOf
apoc.coll.indexOf
|
||
|
Cypher’s
coll.insert
apoc.coll.insert
|
||
|
Cypher’s
coll.max
apoc.coll.max
|
||
|
Cypher’s
coll.min
apoc.coll.min
|
||
|
|
Cypher’s
reduce + CASE expression
apoc.coll.occurrences
|
|
|
Cypher’s list comprehension
apoc.coll.pairs
|
||
|
Cypher’s list comprehension
apoc.coll.pairsMin
|
||
|
Cypher’s list comprehension
apoc.coll.partition
|
||
|
Cypher’s
rand
apoc.coll.randomItem
|
||
|
Cypher’s
coll.remove
apoc.coll.remove
|
||
|
Cypher’s
coll.sort
apoc.coll.sort
|
||
|
|
Cypher’s
COLLECT {} + ORDER BY clause
apoc.coll.sortNodes
|
|
|
Cypher’s
UNWIND and stDev
apoc.coll.stdev
|
||
|
Cypher’s
reduce
apoc.coll.sum
|
||
|
Cypher’s
reduce and toIntegerList
apoc.coll.sumLongs
|
||
|
Cypher’s
coll.distinct
apoc.coll.toSet
|
||
|
Cypher’s list concatenation
apoc.coll.unionAll
|
||
|
|
Cypher’s
UNWIND, COLLECT {}, and range function
apoc.coll.zip
|
|
|
|
Cypher’s
UNWIND and range function
apoc.coll.zipToRows
|
Conversions (apoc.convert)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
Cypher’s
properties function
apoc.convert.toMap
|
Dynamic creation (apoc.create)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s dynamic labels
apoc.create.addLabels
|
||
|
Cypher’s dynamic labels
apoc.create.node
|
||
|
Cypher’s dynamic labels
apoc.create.nodes
|
||
|
Cypher’s dynamic labels
apoc.create.relationship
|
||
|
Cypher’s dynamic labels
apoc.create.removeLabels
|
||
|
Cypher’s dynamic properties
apoc.create.removeProperties
|
||
|
Cypher’s dynamic properties
apoc.create.removeRelProperties
|
||
|
Cypher’s dynamic labels
apoc.create.setLabels
|
||
|
Cypher’s dynamic properties
apoc.create.setProperties
|
||
|
Cypher’s dynamic properties
apoc.create.setProperty
|
||
|
Cypher’s dynamic properties
apoc.create.setRelProperties
|
||
|
Cypher’s dynamic properties
apoc.create.setRelProperty
|
||
|
Cypher’s
randomUUID function
apoc.create.uuid
|
||
|
Cypher’s
randomUUID function
apoc.create.uuids
|
Dynamic Cypher statements
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
Dynamic read and write statements: |
Cypher’s
SET and REMOVE clauses
apoc.cypher.doIt
|
||
Dynamic read statements: |
Cypher’s
MATCH clause
apoc.cypher.run
|
||
Dynamic read statements: |
Cypher’s
MATCH clause
apoc.cypher.runFirstColumnMany
|
||
Dynamic read statements: |
Cypher’s
MATCH clause
apoc.cypher.runFirstColumnSingle
|
||
Set a global timeout, or if using a driver, a timeout in the driver. |
Set the global timeout
Cypher query
apoc.cypher.runTimeboxed
|
||
Dynamic write statements: |
Cypher’s dynamic labels
apoc.cypher.runWrite
|
Dates (apoc.date)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
|
Cypher’s
format function + date function
apoc.date.convertFormat
|
|
|
Cypher’s
datetime.realtime
apoc.date.currentTimestamp
|
||
|
Cypher’s temporal instance access
apoc.date.field
|
||
|
Corresponding temporal type constructor instead, for example the |
Cypher’s pattern constructors
apoc.date.fields
|
|
|
Cypher’s
format function
apoc.date.format
|
||
|
Cypher’s
datetime function
apoc.date.fromISO8601
|
||
|
Corresponding temporal type constructor instead, for example the |
Cypher’s pattern constructors
apoc.date.parse
|
|
|
The |
Cypher’s
toString function
apoc.date.toISO8601
|
Write conditionals (apoc.do)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s conditional queries
apoc.do.case
|
||
|
Cypher’s conditional queries
apoc.do.when
|
Importing CSV files (apoc.import)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
Cypher’s
LOAD CSV
apoc.import.csv
|
Node labels (apoc.label)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
Cypher’s label expressions
apoc.label.exists
|
Maps (apoc.map)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s map comprehension
apoc.map.clean
|
||
|
Cypher’s map Comprehension
apoc.map.fromLists
|
||
|
Cypher’s map comprehension
apoc.map.fromNodes
|
||
|
Cypher’s map comprehension
apoc.map.fromPairs
|
||
|
Cypher’s map comprehension
apoc.map.fromValues
|
||
Cypher’s
CASE expression
Cypher’s
coalesce function
apoc.map.get
|
|||
|
Cypher’s map comprehension
apoc.map.groupBy
|
||
|
Cypher’s map addition
apoc.map.merge
|
||
Cypher’s map access
apoc.map.mget
|
|||
Cypher’s map comprehension
apoc.map.removeKeys
|
|||
Cypher’s map comprehension
apoc.map.setLists
|
|||
Cypher’s map comprehension
apoc.map.setPairs
|
|||
Cypher’s map comprehension
apoc.map.setValues
|
|||
Cypher’s list comprehension and
coll.sort function
apoc.map.sortedProperties
|
|||
Cypher’s list comprehension
apoc.map.values
|
Maths (apoc.math)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s
cosh function
apoc.math.cosh
|
||
|
Cypher’s
coth function
apoc.math.coth
|
||
Cypher’s
cosh function
apoc.math.sech
|
|||
Cypher’s
exp function
apoc.math.sigmoid
|
|||
Cypher’s
exp function
apoc.math.sigmoidPrime
|
|||
|
Cypher’s
sinh function
apoc.math.sinh
|
||
|
Cypher’s
tanh function
apoc.math.tanh
|
Merge (apoc.merge)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
Cypher’s
MERGE clause
apoc.merge.node
|
|||
Cypher’s
MERGE
apoc.merge.nodeWithStats
|
The Cypher equivalent does not return |
||
Cypher’s
MERGE clause
apoc.merge.node.eager
|
|||
Cypher’s
MERGE clause
apoc.merge.relationship
|
Metadata (apoc.meta)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s type predicate expression
apoc.meta.cypher.isType
|
||
|
Cypher’s
valueType function
apoc.meta.cypher.type
|
||
Neo4j’s
db.schema.visualization procedure
apoc.meta.graph
|
|||
Cypher’s
count function
apoc.meta.nodes.count
|
Nodes (apoc.node, apoc.nodes)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s
COUNT {}
apoc.node.degree
|
||
|
Cypher’s
COUNT {} and pattern matching
apoc.node.degree.in
|
||
|
Cypher’s
COUNT {} and pattern matching
apoc.node.degree.out
|
||
|
Cypher’s
EXISTS {}
apoc.node.relationship.exists
|
||
|
Cypher’s
EXISTS {}
apoc.node.relationship.exists
|
||
Cypher’s
COLLECT {} and type function
apoc.node.relationship.types
|
|||
Cypher’s
EXISTS {} subquery
apoc.nodes.connected
|
|||
|
Cypher’s
CALL {…} IN TRANSACTIONS
apoc.nodes.delete
|
||
Using Cypher’s
id
apoc.nodes.get
|
|||
Using Cypher
UNWIND
apoc.nodes.link
|
|||
Cypher’s
EXISTS {}
apoc.nodes.relationships.exist
|
|||
|
Using Cypher’s
id function
apoc.nodes.rels
|
Paths (apoc.path)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s
nodes, relationships, and reduce functions
apoc.path.elements
|
Periodic execution (apoc.periodic)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Using Cypher
CALL {…} IN CONCURRENT TRANSACTIONS
apoc.periodic.iterate
|
Refactoring (apoc.refactor)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Dynamic read and write statements: |
Cypher’s dynamic labels
apoc.refactor.cloneNodes
|
|
Dynamic read and write statements: |
Cypher’s dynamic labels
apoc.refactor.cloneNodes
|
||
Dynamic read and write statements: |
Using Cypher
apoc.refactor.collapseNode
|
||
Dynamic read and write statements: |
Using Cypher
apoc.refactor.extractNode
|
||
Dynamic read and write statements: |
Using Cypher dynamic labels
apoc.refactor.from
|
||
Dynamic read and write statements: |
Using Cypher’s dynamic labels
apoc.refactor.invert
|
||
|
Using Cypher’s
SET
apoc.refactor.rename.label
|
||
|
Using Cypher’s
REMOVE
apoc.refactor.rename.nodeProperty
|
||
|
Dynamic |
Using Cypher
apoc.refactor.rename.type
|
|
|
Using Cypher’s
REMOVE
apoc.refactor.rename.typeProperty
|
||
|
Dynamic |
Using Cypher
apoc.refactor.setType
|
Temporals (apoc.temporal)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
|
Cypher’s
format function
apoc.temporal.format
|
||
|
Cypher’s
format function
apoc.temporal.formatDuration
|
||
|
Corresponding temporal type constructor, for example the |
Cypher’s
datetime function
apoc.temporal.toZonedTemporal
|
Texts (apoc.text)
| APOC | Cypher equivalent | Example | Caveats |
|---|---|---|---|
Cypher’s string interpolation
apoc.text.format
|
|||
|
Cypher’s
string.indexOf function
apoc.text.indexOf
|
||
|
Cypher’s
string.join function
apoc.text.join
|
||
|
Cypher’s
string.regexReplace
apoc.text.replace
|