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.
Last verified against Neo4j 2026.10.

For more information about APOC, Neo4j, and Cypher versions, see the APOC and Cypher versions page.

Conditionals (apoc)

APOC Cypher equivalent Example Caveats

apoc.case Deprecated in Cypher 25

Conditional queries

Cypher’s conditional queries
WHEN false THEN RETURN {b: "firstFalse"} AS value
WHEN false THEN RETURN {b: "secondFalse"} AS value
WHEN true THEN RETURN {b: "firstTrue"} AS value
apoc.case
CALL apoc.case([
  false, 'RETURN "firstFalse" as b',
  false, 'RETURN "secondFalse" as b',
  true, 'RETURN "firstTrue" as b'
])

apoc.when Deprecated in Cypher 25

Conditional queries

Cypher’s conditional queries
WHEN false THEN RETURN {b: 7} AS value
ELSE RETURN {} AS value
apoc.when
CALL apoc.when(false, 'RETURN 7 as b')

Aggregations (apoc.agg)

APOC Cypher equivalent Example Caveats

apoc.agg.first

CALL subqueries

Cypher’s CALL subquery
MATCH (p:Person)
CALL (p) {
    MATCH (p)-[:ACTED_IN]->(movie)
    RETURN movie ORDER BY movie.released ASC LIMIT 1
}
RETURN p.name AS person, movie AS earliestMovie ORDER BY p
apoc.agg.first
MATCH (p:Person)-[:ACTED_IN]->(movie)
WITH p, movie
ORDER BY p, movie.released
RETURN p.name AS person, apoc.agg.first(movie) AS earliestMovie;

apoc.agg.graph Deprecated in Cypher 25

COLLECT subqueries

Cypher’s COLLECT {}
MATCH path = (person:Person)-[:ACTED_IN]->(movie)
WHERE movie.released < 1998
RETURN
  COLLECT {
    UNWIND nodes(path) AS n
    RETURN DISTINCT n
  } AS nodes,
  COLLECT {
    UNWIND relationships(path) AS r
    RETURN DISTINCT r
  } AS relationships
apoc.agg.graph
MATCH path = (person:Person)-[:ACTED_IN]->(movie)
WHERE movie.released < 1998
WITH apoc.agg.graph(path) AS g
RETURN g.nodes AS nodes, g.relationships AS relationships

apoc.agg.last

CALL subqueries

Cypher’s CALL subquery
MATCH (p:Person)
CALL (p) {
    MATCH (p)-[:ACTED_IN]->(movie)
    RETURN movie ORDER BY movie.released DESC LIMIT 1
}
RETURN p.name AS person, movie AS earliestMovie ORDER BY p
apoc.agg.last
MATCH (p:Person)-[:ACTED_IN]->(movie)
WITH p, movie
ORDER BY p, movie.released
RETURN p.name AS person, apoc.agg.last(movie) AS latestMovie;

apoc.agg.median

COLLECT subqueries and CASE expressions.

Cypher’s COLLECT {} + CASE expression
MATCH (p:Person)
WITH p, COLLECT { MATCH (p)-[:ACTED_IN]->(movie) RETURN movie.released ORDER BY movie.released } AS releasedYears
WITH p.name AS name, releasedYears, size(releasedYears) AS size
RETURN name,
    CASE size % 2
        WHEN 1 THEN releasedYears[size / 2]
        ELSE (releasedYears[size / 2 - 1] + releasedYears[size / 2]) / 2
    END AS medianReleaseYear
apoc.agg.median
MATCH (p:Person)-[:ACTED_IN]->(movie)
RETURN p.name AS person, apoc.agg.median(movie.released) AS medianReleaseYear

apoc.agg.nth

OFFSET and LIMIT clauses.

Cypher’s OFFSET and LIMIT
MATCH (p:Person)
CALL (p) {
  MATCH (p)-[:ACTED_IN]->(movie)
  RETURN movie ORDER BY p, movie.released OFFSET 1 LIMIT 1
}
RETURN p.name AS person, movie AS nthMovie
apoc.agg.nth
MATCH (p:Person)-[:ACTED_IN]->(movie)
WITH p, movie
ORDER BY p, movie.released
RETURN p.name AS person, apoc.agg.nth(movie, 1) AS nthMovie

apoc.agg.product Deprecated in Cypher 25

reduce function

Cypher’s reduce
WITH range(1,10) AS values
RETURN reduce(x = 1, i IN values | x * i) AS result,
       1*2*3*4*5*6*7*8*9*10 AS manualEquivalent
apoc.agg.product
UNWIND range(1,10) AS values
RETURN apoc.agg.product(values) AS result,
       1*2*3*4*5*6*7*8*9*10 AS manualEquivalent

apoc.agg.slice

COLLECT subqueries

Cypher’s COLLECT {}
MATCH (p:Person)
WITH p, COLLECT {
  MATCH (p)-[:ACTED_IN]->(movie)
  WITH p, movie ORDER BY p, movie.released
  RETURN movie LIMIT 3
} AS movies
RETURN p.name AS person, movies
apoc.agg.slice
MATCH (p:Person)-[:ACTED_IN]->(movie)
WITH p, movie
ORDER BY p, movie.released
RETURN p.name AS person, apoc.agg.slice(movie, 0, 3) AS movies

Algorithms (apoc.algo)

APOC Cypher equivalent Example Caveats

apoc.map.cover Deprecated in Cypher 25

IN predicate

Cypher’s IN predicate
WITH COLLECT {
  MATCH (person:Person)
  WHERE person.name IN ["Keanu Reeves", "Carrie-Anne Moss"]
  RETURN person
} AS people
UNWIND people AS person
MATCH (person)-[rel]->(otherPerson)
WHERE otherPerson IN people
RETURN person AS startNode, rel, otherPerson AS endNode
apoc.algo.cover
WITH COLLECT {
  MATCH (person:Person)
  WHERE person.name IN ["Keanu Reeves", "Carrie-Anne Moss"]
  RETURN person
} AS people
CALL apoc.algo.cover(people)
YIELD rel
RETURN  startNode(rel) AS startNode, rel, endNode(rel) AS endNode

Property access (apoc.any)

APOC Cypher equivalent Example Caveats

apoc.any.properties

properties function

Cypher’s properties function
MATCH (s:Student)
RETURN properties({value: s.score}) AS properties;
apoc.any.properties
MATCH (s:Student)
CALL apoc.create.vNode(['Score'],{value: s.score})
YIELD node
RETURN apoc.any.properties(node) AS properties;

Cypher equivalent does not work on all runtimes for virtual nodes.

apoc.any.property

Property access

Cypher’s property access operator
MATCH (s:Student)
RETURN {value: s.score}.value AS score
apoc.any.property
MATCH (s:Student)
RETURN apoc.any.property({value: s.score}, "value") AS score

Cypher’s equivalent does not work on all runtimes for virtual nodes.

Collections (apoc.coll)

APOC Cypher equivalent Example Caveats

apoc.coll.contains Deprecated in Cypher 25

IN predicate

Cypher’s IN predicate
RETURN 4 IN [1,2,3,4,5] AS output
apoc.coll.contains
RETURN apoc.coll.contains([1,2,3,4,5], 4) AS output

apoc.coll.containsAll Deprecated in Cypher 25

all function

Cypher’s all
WITH [1,2,3,4,5] AS mainList, [3,7] AS sublist
RETURN all(x IN sublist WHERE x IN mainList) AS output
apoc.coll.containsAll
WITH [1,2,3,4,5] AS mainList, [3,7] AS sublist
RETURN apoc.coll.containsAll(mainList, sublist) AS output

apoc.coll.fill Deprecated in Cypher 25

List comprehension

Cypher’s list comprehension
RETURN [i IN range(1, 2) | 'abc'] as output
apoc.coll.fill
RETURN apoc.coll.fill('abc', 2) as output

apoc.coll.flatten Deprecated in Cypher 25

coll.flatten function

Cypher’s coll.flatten
RETURN coll.flatten([1,2,3,[4,5,6]]) AS output
apoc.coll.flatten
RETURN apoc.coll.flatten([1,2,3,[4,5,6]]) AS output

apoc.coll.indexOf Deprecated in Cypher 25

coll.indexOf function

Cypher’s coll.indexOf
RETURN coll.indexOf([1,3,5,7,9], 3) AS output
apoc.coll.indexOf
RETURN apoc.coll.indexOf([1,3,5,7,9], 3) AS output

apoc.coll.insert Deprecated in Cypher 25

coll.insert function

Cypher’s coll.insert
RETURN coll.insert([1,3,5,7,9], 3, 11) AS output
apoc.coll.insert
RETURN apoc.coll.insert([1,3,5,7,9], 3, 11) AS output

apoc.coll.max Deprecated in Cypher 25

coll.max function

Cypher’s coll.max
RETURN coll.max([1,2,3,4,5]) AS output
apoc.coll.max
RETURN apoc.coll.max([1,2,3,4,5]) AS output

apoc.coll.min Deprecated in Cypher 25

coll.min function

Cypher’s coll.min
RETURN coll.min([1,2,3,4,5]) AS output
apoc.coll.min
RETURN apoc.coll.min([1,2,3,4,5]) AS output

apoc.coll.occurrences Deprecated in Cypher 25

reduce function together with a CASE expression

Cypher’s reduce + CASE expression
WITH [1,3,5,7,9,9] AS list, 9 AS match
RETURN reduce(count = 0, x IN list | count + CASE WHEN x = match THEN 1 ELSE 0 END) AS output
apoc.coll.occurrences
WITH [1,3,5,7,9,9] AS list, 9 AS match
RETURN apoc.coll.occurrences(list, match) AS output

apoc.coll.pairs Deprecated in Cypher 25

List comprehension

Cypher’s list comprehension
WITH [1,2,3,4,5] AS list
RETURN [i IN range(0, size(list) - 1) | [list[i], list[i + 1]]] AS value
apoc.coll.pairs
RETURN apoc.coll.pairs([1,2,3,4,5]) AS output

apoc.coll.pairsMin Deprecated in Cypher 25

List comprehension

Cypher’s list comprehension
WITH [1,2,3,4,5] AS list
RETURN [i IN range(0, size(list) - 2) | [list[i], list[i + 1]]] AS value
apoc.coll.pairsMin
RETURN apoc.coll.pairsMin([1,2,3,4,5]) AS output

apoc.coll.partition Deprecated in Cypher 25

List comprehension

Cypher’s list comprehension
WITH [1,2,3,4,5] AS list, 2 AS offset
RETURN [i IN range(0, size(list), offset) | list[i..i + offset]] AS value
apoc.coll.partition
WITH [1,2,3,4,5] AS list, 2 AS offset
RETURN apoc.coll.partition(list, offset) AS value

apoc.coll.randomItem Deprecated in Cypher 25

rand function

Cypher’s rand
WITH [1,3,5,7,9] AS list
WITH list, toInteger(rand() * size(list)) AS randomInt
RETURN list[randomInt] AS output
apoc.coll.randomItem
RETURN apoc.coll.randomItem([1,3,5,7,9]) AS output

apoc.coll.remove Deprecated in Cypher 25

coll.remove function

Cypher’s coll.remove
RETURN coll.remove([1,3,5,7,9], 4) AS output
apoc.coll.remove
RETURN apoc.coll.remove([1,3,5,7,9], 4) AS output

apoc.coll.sort Deprecated in Cypher 25

coll.sort function

Cypher’s coll.sort
RETURN coll.sort([5,4,2,3,1]) AS output
apoc.coll.sort
RETURN apoc.coll.sort([5,4,2,3,1]) AS output

apoc.coll.sortNodes Deprecated in Cypher 25

COLLECT subqueries together with ORDER BY clause

Cypher’s COLLECT {} + ORDER BY clause
RETURN COLLECT {
    MATCH (person:Person)
    RETURN person ORDER BY person.name DESC
} AS output
apoc.coll.sortNodes
MATCH (person:Person)
WITH collect(person) AS people
RETURN apoc.coll.sortNodes(people, 'name') AS output

apoc.coll.stdev Deprecated in Cypher 25

stDev and stDevP functions.

Cypher’s UNWIND and stDev
UNWIND [1,2,3,4,5] AS x
RETURN stDev(x) AS output
apoc.coll.stdev
WITH [1,2,3,4,5] AS list
RETURN apoc.coll.stdev(list) AS output

apoc.coll.sum Deprecated in Cypher 25

reduce function

Cypher’s reduce
WITH [1,2,3,4,5] AS list
RETURN reduce(sum = 0.0, x IN list | sum + x) AS output
apoc.coll.sum
WITH [1,2,3,4,5] AS list
RETURN apoc.coll.sum(list) AS output

apoc.coll.sumLongs Deprecated in Cypher 25

reduce function

Cypher’s reduce and toIntegerList
WITH [1.5,2.5,3.6,4.3,5.2] AS list
RETURN reduce(sum = 0, x IN toIntegerList(list) | sum + x) AS output
apoc.coll.sumLongs
WITH [1.5,2.5,3.6,4.3,5.2] AS list
RETURN apoc.coll.sumLongs(list) AS output

apoc.coll.toSet Deprecated in Cypher 25

coll.distinct function

Cypher’s coll.distinct
RETURN coll.distinct([1,1,2,1,3,4,1]) AS output
apoc.coll.toSet
RETURN apoc.coll.toSet([1,1,2,1,3,4,1]) AS output

apoc.coll.unionAll Deprecated in Cypher 25

List concatenation

Cypher’s list concatenation
RETURN [1,2,3,4,5] + [3,4,5,6,7] AS output
apoc.coll.unionAll
RETURN apoc.coll.unionAll([1,2,3,4,5], [3,4,5,6,7]) AS output

apoc.coll.zip Deprecated in Cypher 25

UNWIND together with range function

Cypher’s UNWIND, COLLECT {}, and range function
WITH [1, 2, 3] AS list1, ["a", "b", "c"] AS list2
RETURN COLLECT {
    UNWIND range(0, size(list1)-1) AS i
    RETURN [list1[i], list2[i]]
} AS result
apoc.coll.zip
WITH [1, 2, 3] AS list1, ["a", "b", "c"] AS list2
RETURN apoc.coll.zip(list1, list2) as output

apoc.coll.zipToRows Deprecated in Cypher 25

UNWIND and range function

Cypher’s UNWIND and range function
WITH [1, 2, 3] AS list1, ["a", "b", "c"] AS list2
UNWIND range(0, size(list1) - 1) AS i
RETURN [list1[i], list2[i]]
apoc.coll.zipToRows
WITH [1, 2, 3] AS list1, ["a", "b", "c"] AS list2
CALL apoc.coll.zipToRows(list1, list2)
YIELD value
RETURN value

Conversions (apoc.convert)

APOC Cypher equivalent Example Caveats

apoc.coll.convert.toMap

properties function

Cypher’s properties function
CREATE (node:Node {id: 4})
RETURN properties(node) AS output
apoc.convert.toMap
CREATE (node:Node {id: 4})
RETURN apoc.convert.toMap(node) AS output

Dynamic creation (apoc.create)

APOC Cypher equivalent Example Caveats

apoc.create.addLabels Deprecated in Cypher 25

SET dynamic labels

Cypher’s dynamic labels
MATCH (n:Movie)
SET n:$(n.genre)
REMOVE n.genre
RETURN n
apoc.create.addLabels
MATCH (n:Movie)
CALL apoc.create.addLabels( n, [ n.genre ] )
YIELD node
REMOVE node.genre
RETURN node

apoc.create.node Deprecated in Cypher 25

CREATE using dynamic node labels and relationship types

Cypher’s dynamic labels
CREATE (node:$($labels) $properties)
RETURN node
apoc.create.node
CALL apoc.create.node($labels, $properties)

apoc.create.nodes Deprecated in Cypher 25

CREATE using dynamic node labels and relationship types

Cypher’s dynamic labels
UNWIND $properties AS propertyMap
CREATE (node:$($labels))
SET n = propertyMap
RETURN node;
apoc.create.nodes
CALL apoc.create.nodes($labels, $properties);

apoc.create.relationship Deprecated in Cypher 25

CREATE using dynamic node labels and relationship types

Cypher’s dynamic labels
MATCH (p:Person {name: "Tom Hanks"})
MATCH (m:Movie {title:"You've Got Mail"})
CREATE (p)-[rel:$($relType) $properties]->(m)
RETURN rel
apoc.create.relationship
MATCH (p:Person {name: "Tom Hanks"})
MATCH (m:Movie {title:"You've Got Mail"})
CALL apoc.create.relationship(p, $relType, $properties, m)
YIELD rel
RETURN rel

apoc.create.removeLabels Deprecated in Cypher 25

REMOVE dynamic labels

Cypher’s dynamic labels
CALL db.labels()
YIELD label WHERE label <> "Person"
WITH collect(label) AS labels
MATCH (p:Person)
REMOVE p:$(labels)
RETURN p, labels(p) AS labels
apoc.create.removeLabels
CALL db.labels()
YIELD label WHERE label <> "Person"
WITH collect(label) AS labels
MATCH (p:Person)
WITH collect(p) AS people, labels
CALL apoc.create.removeLabels(people, labels)
YIELD node
RETURN node, labels(node) AS labels

apoc.create.removeProperties Deprecated in Cypher 25

REMOVE properties dynamically

Cypher’s dynamic properties
CALL db.propertyKeys()
YIELD propertyKey WHERE propertyKey <> "name"
WITH collect(propertyKey) AS propertyKeys
MATCH (p:Person)
FOREACH (key IN propertyKeys | REMOVE p[key])
RETURN DISTINCT p
apoc.create.removeProperties
CALL db.propertyKeys()
YIELD propertyKey WHERE propertyKey <> "name"
WITH collect(propertyKey) AS propertyKeys
MATCH (p:Person)
WITH collect(p) AS nodes, propertyKeys
CALL apoc.create.removeProperties(nodes, propertyKeys)
YIELD node
RETURN node

apoc.create.removeRelProperties Deprecated in Cypher 25

REMOVE properties dynamically

Cypher’s dynamic properties
MATCH (p1:Person)-[friends:FRIENDS]->(p2:Person)
FOREACH (key IN keys(friends) | REMOVE friends[key])
RETURN DISTINCT p1.name AS start, friends, p2.name AS end
apoc.create.removeRelProperties
CALL db.propertyKeys()
YIELD propertyKey
WITH collect(propertyKey) AS propertyKeys
MATCH (:Person)-[friends:FRIENDS]->(:Person)
WITH collect(friends) AS friendsRels, propertyKeys
CALL apoc.create.removeRelProperties(friendsRels, propertyKeys)
YIELD rel
RETURN startNode(rel).name AS start, rel, endNode(rel).name AS end

apoc.create.setLabels Deprecated in Cypher 25

SET dynamic labels

Cypher’s dynamic labels
MATCH (n:Movie)
REMOVE n:$(labels(n))
SET n:$(n.genre)
REMOVE n.genre
RETURN n
apoc.create.setLabels
MATCH (n:Movie)
CALL apoc.create.setLabels( n, [ n.genre ] )
YIELD node
REMOVE node.genre
RETURN node

apoc.create.setProperties Deprecated in Cypher 25

SET dynamic properties

Cypher’s dynamic properties
MATCH (p:Person)
FOREACH (k IN keys(p) | SET p[k + "Copy"] = p[k])
RETURN p AS node
apoc.create.setProperties
MATCH (p:Person)
WITH p, keys(p) AS keys
CALL apoc.create.setProperties(p,[k in keys | k + "Copy"], [k in keys | p[k]])
YIELD node
RETURN node

apoc.create.setProperty Deprecated in Cypher 25

SET dynamic properties

Cypher’s dynamic properties
MATCH (stop:Stop)
UNWIND ["arrival", "departure"] AS key
WITH stop, key + "Time" AS newKey, time(stop[key]) AS time
SET stop[newKey] = time
RETURN stop AS node
apoc.create.setProperty
MATCH (stop:Stop)
UNWIND ["arrival", "departure"] AS key
WITH stop, key + "Time" AS newKey, time(stop[key]) AS time
CALL apoc.create.setProperty(stop, newKey, time)
YIELD node
RETURN node

apoc.create.setRelProperties Deprecated in Cypher 25

SET dynamic properties

Cypher’s dynamic properties
MATCH (p1:Person)-[friends:FRIENDS]->(p2:Person)
FOREACH (k IN keys(friends) | SET friends[k + "Copy"] = friends[k])
RETURN DISTINCT p1.name AS start, friends, p2.name AS end;
apoc.create.setRelProperties
MATCH (:Person)-[friends:FRIENDS]->(:Person)
WITH friends, keys(friends) AS keys
CALL apoc.create.setRelProperties(friends,[k in keys | k + "Copy"], [k in keys | friends[k]])
YIELD rel
RETURN startNode(rel).name AS start, rel, endNode(rel).name AS end

apoc.create.setRelProperty Deprecated in Cypher 25

SET dynamic properties

Cypher’s dynamic properties
MATCH (:Station)-[journey:JOURNEY]->(:Station)
UNWIND ["arrival", "departure"] AS key
WITH stop, key + "Time" AS newKey, time(journey[key]) AS time
SET journey[newKey] = time
RETURN journey
apoc.create.setRelProperty
MATCH (:Station)-[journey:JOURNEY]->(:Station)
UNWIND ["arrival", "departure"] AS key
WITH journey, key + "Time" AS newKey, time(journey[key]) AS time
CALL apoc.create.setRelProperty(journey, newKey, time)
YIELD rel
RETURN rel;

apoc.create.uuid Deprecated in Cypher 5 Removed in Cypher 25

randomUUID function

Cypher’s randomUUID function
RETURN randomUUID() AS Output
apoc.create.uuid
RETURN apoc.create.uuid() AS Output

apoc.create.uuid Deprecated in Cypher 5 Removed in Cypher 25

randomUUID function

Cypher’s randomUUID function
UNWIND range(0, 9) AS row
RETURN row, randomUUID() AS uuid
apoc.create.uuids
CALL apoc.create.uuids(10)

Dynamic Cypher statements

APOC Cypher equivalent Example Caveats

apoc.cypher.doIt

Cypher’s SET and REMOVE clauses
MATCH (node)
WITH node, labels(node)[0] AS label
REMOVE node:$(label)
SET node:$(apoc.text.capitalize(toLower(label)))
RETURN node AS value;
apoc.cypher.doIt
MATCH (node)
WITH node, labels(node)[0] AS label
CALL apoc.cypher.doIt(
  "WITH $node AS node
   REMOVE node:" + label + "\n" +
  "SET node:" + apoc.text.capitalize(toLower(label)) + "\n" +
  "RETURN node",
  {node: node})
YIELD value
RETURN value

apoc.cypher.run

Dynamic read statements:

Cypher’s MATCH clause
CALL db.labels()
YIELD label
MATCH (n:$(label))
RETURN label, count(n) AS count;
apoc.cypher.run
CALL db.labels()
YIELD label
CALL apoc.cypher.run("MATCH (:" + label + ") RETURN count(*) AS count", {})
YIELD value
RETURN label, value.count AS count;

apoc.cypher.runFirstColumnMany

Dynamic read statements:

Cypher’s MATCH clause
CALL db.labels()
YIELD label
RETURN label, COLLECT {
    MATCH (n:$(label))
    WITH DISTINCT keys(n) AS keys
    RETURN DISTINCT apoc.coll.sort(keys)
};
apoc.cypher.runFirstColumnMany
CALL db.labels()
YIELD label
RETURN label,
       apoc.cypher.runFirstColumnMany(
          "MATCH (n:`" + label + "`)
           WITH DISTINCT keys(n) AS keys
           RETURN DISTINCT apoc.coll.sort(keys)",
          {}) AS keys;

apoc.cypher.runFirstColumnSingle

Dynamic read statements:

Cypher’s MATCH clause
CALL db.labels()
YIELD label
MATCH (n:$(label))
RETURN label, count(n);
apoc.cypher.runFirstColumnSingle
CALL db.labels()
YIELD label
RETURN label,
       apoc.cypher.runFirstColumnSingle("MATCH (:" + label + ") RETURN count(*)", {}) AS count;

apoc.cypher.runWrite

Set a global timeout, or if using a driver, a timeout in the driver.

Set the global timeout
CALL dbms.setConfigValue('db.transaction.timeout', '100ms');
Cypher query
MATCH (n:Node), (m:Node)
WHERE n <> m
MATCH path = shortestPath((n)-[:CONNECTED_TO*]-(m))
RETURN n.uuid, m.uuid, length(path) AS path;
apoc.cypher.runTimeboxed
CALL apoc.cypher.runTimeboxed("match (n:Node), (m:Node)
WHERE n <> m
MATCH path = shortestpath((n)-[:CONNECTED_TO*]-(m))
RETURN n, m, length(path) AS path", {}, 100)
YIELD value
RETURN value.n.uuid, value.m.uuid, value.path;

apoc.cypher.runWrite

Cypher’s dynamic labels
MATCH (p:$($label) {name: 'Alice'})
SET p.age = 31
RETURN p.name AS name, p.age AS age
apoc.cypher.runWrite
CALL apoc.cypher.runWrite(
  'MATCH (p:Person {name: $name})
  SET p.age = $newAge
  RETURN p.name AS name, p.age AS age',
  {name: 'Alice', newAge: 31}
)
YIELD value
RETURN value.name AS name, value.age AS age

Dates (apoc.date)

APOC Cypher equivalent Example Caveats

apoc.date.convertFormat Deprecated in Cypher 25

format function with the the corresponding temporal type constructor instead, for example the date function.

Cypher’s format function + date function
RETURN format(date("2020-11-04"), "yyyyMMdd") AS output
apoc.date.convertFormat
RETURN apoc.date.convertFormat("2020-11-04", "date", "basic_date") AS output

apoc.date.currentTimestamp Deprecated in Cypher 25

datetime.realtime function

Cypher’s datetime.realtime
WITH datetime.realtime() AS output
RETURN output.epochMillis AS outputinMs, output AS datetime;
apoc.date.currentTimestamp
WITH apoc.date.currentTimestamp() AS outputInMs
RETURN outputinMs, datetime({epochMillis: output}) AS datetime;

apoc.date.field Deprecated in Cypher 25

Temporal components

Cypher’s temporal instance access
WITH datetime("2020-11-04T10:30:00") AS datetime
RETURN datetime.hour AS hour;
apoc.date.field
WITH datetime("2020-11-04T10:30:00").epochMillis AS datetime
RETURN apoc.date.field(datetime, "hours") AS hour;

apoc.date.fields Deprecated in Cypher 25

Corresponding temporal type constructor instead, for example the date function.

Cypher’s pattern constructors
RETURN date("2020-11-04") AS fields;
apoc.date.fields
RETURN apoc.date.fields("2020-11-04", "yyyy-MM-dd") AS fields;

apoc.date.format Deprecated in Cypher 25

format function

Cypher’s format function
RETURN format(datetime("2020-11-04T11:23:22"), "yyyy-MM-dd") AS output
apoc.date.format
WITH datetime("2020-11-04T11:23:22").epochMillis AS datetime
RETURN apoc.date.format(datetime, "ms", "yyyy-MM-dd") AS output

apoc.date.format Deprecated in Cypher 25

datetime function

Cypher’s datetime function
RETURN datetime('2020-11-04T12:21:33.000Z').epochMillis AS outputInMs;
apoc.date.fromISO8601
RETURN apoc.date.fromISO8601('2020-11-04T12:21:33.000Z') AS outputInMs;

apoc.date.parse Deprecated in Cypher 25

Corresponding temporal type constructor instead, for example the date function.

Cypher’s pattern constructors
RETURN datetime("2020-11-04").epochMillis AS outputInMs;
apoc.date.parse
RETURN apoc.date.parse("2020-11-04", "ms", "yyyy-MM-dd") AS outputInMs;

apoc.date.toISO8601 Deprecated in Cypher 25

The toString function function, which automatically converts temporal values into STRING values formatted to the ISO8601 standard.

Cypher’s toString function
RETURN toString(datetime()) AS iso8601
apoc.date.toISO8601
RETURN apoc.date.toISO8601(datetime().epochMillis, "ms") AS iso8601

Write conditionals (apoc.do)

APOC Cypher equivalent Example Caveats

apoc.do.case Deprecated in Cypher 25

Conditional queries

Cypher’s conditional queries
WHEN false THEN CREATE (a:Node { name:"A" }) RETURN a AS node
WHEN true THEN CREATE (b:Node { name:"B" }) RETURN b AS node
ELSE CREATE (c:Node { name:"C" }) RETURN c AS node
apoc.do.case
CALL apoc.do.case([
  false,
  'CREATE (a:Node { name:"A" }) RETURN a AS node',
  true,
  'CREATE (b:Node { name:"B" }) RETURN b AS node'
  ],
  'CREATE (c:Node { name:"C" }) RETURN c AS node',{})
YIELD value
RETURN value.node AS node;

apoc.do.when Deprecated in Cypher 25

Conditional queries

Cypher’s conditional queries
WHEN true THEN CREATE (a:Node { name:"A" }) RETURN a AS node
ELSE CREATE (b:Node { name:"B" }) RETURN b AS node
apoc.do.when
CALL apoc.do.when(true,
  'CREATE (a:Node { name:"A" }) RETURN a AS node',
  'CREATE (b:Node { name:"B" }) RETURN b AS node',
  {}
)
YIELD value
RETURN value.node AS node;

Importing CSV files (apoc.import)

APOC Cypher equivalent Example Caveats

apoc.import.csv

LOAD CSV

Cypher’s LOAD CSV
LOAD CSV WITH HEADERS FROM 'file:///persons.csv' AS line
CREATE (:Person { id: line['id:ID'], name: line['name:STRING'] })
RETURN count(*) AS nodes
apoc.import.csv
CALL apoc.import.csv([{fileName: 'file:/persons.csv', labels: ['Person']}], [], {});
YIELD nodes
RETURN nodes

Node labels (apoc.label)

APOC Cypher equivalent Example Caveats

apoc.label.exists

Label expressions

Cypher’s label expressions
MATCH (s1 {name: 'Priya'})
RETURN s1:Student AS output
apoc.label.exists
MATCH (s1 {name: 'Priya'})
RETURN apoc.label.exists(s1, "Student") AS output

Maps (apoc.map)

APOC Cypher equivalent Example Caveats

apoc.map.clean Deprecated in Cypher 25

Map comprehension

Cypher’s map comprehension
WITH {name: "Cristiano Ronaldo", club: ""} AS map
RETURN { k: v IN map WHERE v <> "" | k: v } AS output
apoc.map.clean
WITH {name: "Cristiano Ronaldo", club: ""} AS map
RETURN apoc.map.clean(map, [], [""]) AS output

apoc.map.fromLists Deprecated in Cypher 25

Map comprehension

Cypher’s map Comprehension
WITH ["name", "dob"] AS keys,
     ["Cristiano Ronaldo", date("1985-02-05")] AS values
RETURN { i IN range(0, size(keys) - 1) | keys[i]: values[i] } AS output
apoc.map.fromLists
RETURN apoc.map.fromLists(
    ["name", "dob"],
    ["Cristiano Ronaldo", date("1985-02-05")]
) AS output

apoc.map.fromNodes Deprecated in Cypher 25

Map comprehension

Cypher’s map comprehension
MATCH (m:Movie)
WITH collect(m) AS movies
RETURN { m IN movies | m.title: m } AS output
apoc.map.fromNodes
RETURN apoc.map.fromNodes("Movie", "title")

apoc.map.fromPairs Deprecated in Cypher 25

Map comprehension

Cypher’s map comprehension
WITH [["name", "Cristiano Ronaldo"], ["age", date("1985-02-05")]] AS pairs
RETURN { pair IN pairs | pair[0]: pair[1] } AS output
apoc.map.fromPairs
RETURN apoc.map.fromPairs([
    ["name", "Cristiano Ronaldo"],
    ["age", date("1985-02-05")]
]) AS output

apoc.map.fromValues Deprecated in Cypher 25

Map comprehension

Cypher’s map comprehension
WITH ["name", "Cristiano Ronaldo", "age", date("1985-02-05")] AS values
RETURN { i IN range(0, size(values) / 2, 2) | values[i]: values[i + 1] } AS output
apoc.map.fromValues
RETURN apoc.map.fromValues([
    "name", "Cristiano Ronaldo",
    "age", date("1985-02-05")
]) AS output

apoc.map.get

CASE expression or coalesce function.

Cypher’s CASE expression
WITH {name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05")} AS map
RETURN CASE WHEN NOT "missingKey" IN keys(map) THEN "defaultValue" ELSE map["missingKey"] END AS output
Cypher’s coalesce function
WITH {name: "Cristiano Ronaldo", country: "Portugal", dob: date("1985-02-05")} AS map
RETURN coalesce(map["missingKey"], "defaultValue") AS output
apoc.map.get
WITH {name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05")} AS map
RETURN apoc.map.get(map, "missingKey", "defaultValue") AS output

apoc.map.groupBy Deprecated in Cypher 25

Map comprehension

Cypher’s map comprehension
WITH [
	{name: "Cristiano Ronaldo", club: "Juventus"},
    {name: "Lionel Messi", club: "Barcelona"},
    {name: "Aaron Ramsey", club: "Juventus"},
    {name: "Luiz Suarez", club: "Barcelona"}
] AS listOfMaps, "club" AS group
RETURN { map IN listOfMaps | map[group]: map } AS output
apoc.map.groupBy
WITH [
	{name: "Cristiano Ronaldo", club: "Juventus"},
    {name: "Lionel Messi", club: "Barcelona"},
    {name: "Aaron Ramsey", club: "Juventus"},
    {name: "Luiz Suarez", club: "Barcelona"}
] AS listOfMaps, "club" AS group
RETURN apoc.map.groupBy(listOfMaps, groups) AS output

apoc.map.merge Deprecated in Cypher 25

Map addition

Cypher’s map addition
RETURN {name: "Cristiano Ronaldo", dob: date("1985-02-05")} + {country: "Portugal"} AS output
apoc.map.merge
RETURN apoc.map.merge(
    {name: "Cristiano Ronaldo", dob: date("1985-02-05")},
    {country: "Portugal"}
) AS output

apoc.map.mget

Map access

Cypher’s map access
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN [map.name, map.country] AS output
apoc.map.mget
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN apoc.map.mget(map, ["name", "country"]) AS output

apoc.map.removeKeys

Map comprehension

Cypher’s map comprehension
RETURN {k: v IN {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")}
        WHERE NOT k IN ["dob", "country"] | k : v} AS output
apoc.map.removeKeys
RETURN apoc.map.removeKeys(
    {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")},
    ["dob", "country"]
) AS output

apoc.map.setLists

Map comprehension

Cypher’s map comprehension
WITH {name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05")} AS map,
     ["dob", "country"] AS keys,
     [date("1986-02-06"), "Spain"] AS values
RETURN
  {
    k: v IN map
    | k: CASE
      WHEN k IN keys THEN values[coll.indexOf(keys, k)]
      ELSE v
    END
  } AS output
apoc.map.setLists
WITH {name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05")} AS map,
     ["dob", "country"] AS keys,
     [date("1986-02-06"), "Spain"] AS values
RETURN apoc.map.setLists(map, keys, values) AS output

apoc.map.setPairs

Map comprehension

Cypher’s map comprehension
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map,
     {pair IN [["dob", date("1986-02-06")], ["country", "Spain"]] | pair[0] : pair[1]} AS updates
RETURN {k IN keys(map) + keys(updates) | k : CASE WHEN k IN keys(updates) THEN updates[k] ELSE map[k] END} AS output
apoc.map.setPairs
RETURN apoc.map.setPairs(
    {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")},
    [ ["dob", date("1986-02-06")],
      ["country", "Spain"]
    ]
) AS output

apoc.map.setValues

Map comprehension

Cypher’s map comprehension
WITH {name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05")} AS map,
    ["dob", date("1986-02-06"), "country", "Spain"] AS keysAndValues
RETURN
  {
    k: v IN map
    | k: CASE
      WHEN k IN keysAndValues THEN keysAndValues[coll.indexOf(keysAndValues, k) + 1]
      ELSE v
    END
 } AS output
apoc.map.setValues
WITH {name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05")} AS map,
    ["dob", date("1986-02-06"), "country", "Spain"] AS keysAndValues
RETURN apoc.map.setValues(map, keysAndValues) AS output

apoc.map.sortedProperties

List comprehension and coll.sort function.

Cypher’s list comprehension and coll.sort function
WITH {name: "Cristiano Ronaldo", country: "Portugal", dob: date("1985-02-05")} AS map
RETURN [k IN coll.sort(keys(map)) | [k, map[k]]] AS output
apoc.map.sortedProperties
WITH {name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05")} AS map
RETURN apoc.map.sortedProperties(map) AS output

apoc.map.values

List comprehension

Cypher’s list comprehension
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN [k IN ["name", "country", "missingKey"] | map[k]] AS output
apoc.map.values
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN apoc.map.values(map, ["name", "country", "missingKey"], true) AS output

Maths (apoc.math)

APOC Cypher equivalent Example Caveats

apoc.math.cosh Deprecated in Cypher 25

cosh function

Cypher’s cosh function
RETURN cosh(0.7) AS result;
apoc.math.cosh
RETURN apoc.math.cosh(0.7) AS result;

apoc.math.coth Deprecated in Cypher 25

coth function

Cypher’s coth function
RETURN coth(0.7) AS result
apoc.math.coth
RETURN apoc.math.coth(0.7) AS result

apoc.math.sech

cosh function

Cypher’s cosh function
RETURN 1 / cosh(0.7) AS result; // As sech(x) = 1 / cosh(x)
apoc.math.sech
RETURN apoc.math.sech(0.7) AS result;

apoc.math.sigmoid

exp function

Cypher’s exp function
RETURN 1 / (1 + exp(-1)) AS result;
apoc.math.sigmoid
RETURN apoc.math.sigmoid(1) AS result;

apoc.math.sigmoidPrime

exp function

Cypher’s exp function
WITH -1 AS x
WITH x, 1 / (1 + exp(-x)) AS cypherSigmoid
RETURN cypherSigmoid * (1 - cypherSigmoid) AS result
apoc.math.sigmoidPrime
WITH -1 AS x
RETURN apoc.math.sigmoidPrime(x) AS result;

apoc.math.sinh Deprecated in Cypher 25

sinh function

Cypher’s sinh function
RETURN sinh(0.7) AS result;
apoc.math.sinh
RETURN apoc.math.sinh(0.7) AS result;

apoc.math.tanh Deprecated in Cypher 25

tanh function

Cypher’s tanh function
RETURN tanh(0.7) AS result;
apoc.math.tanh
RETURN apoc.math.tanh(0.7) AS result;

Merge (apoc.merge)

APOC Cypher equivalent Example Caveats

apoc.merge.node

MERGE

Cypher’s MERGE clause
MERGE (node:Person:Actor {name: "Tom Hanks"})
ON CREATE SET node.created = datetime()
ON MATCH SET node.lastSeen = datetime()
RETURN node
apoc.merge.node
CALL apoc.merge.node(
  ["Person", "Actor"],
  {name: "Tom Hanks"},
  {created: datetime()},
  {lastSeen: datetime()}
)

apoc.merge.nodeWithStats

MERGE

Cypher’s MERGE
MERGE (node:Person {id: 1})
  ON CREATE SET node.name = 'Alice', node.age = 30
RETURN
  node.id AS id,
  node.name AS name,
  node.age AS age
apoc.merge.nodeWithStats
CALL
  apoc.merge.nodeWithStats(
    ['Person'],
    {id: 1},
    {name: 'Alice', age: 30},
    {}
  )
  YIELD node, stats
RETURN
  node.id AS id,
  node.name AS name,
  node.age AS age,
  stats.nodesCreated AS nodesCreated,
  stats.propertiesSet AS propertiesSet

The Cypher equivalent does not return nodesCreated or propertiesSet as columns. They show up in the query statistics (e.g. "Added 1 label, created 1 node, set 3 properties") instead.

apoc.merge.node.eager

MERGE

Cypher’s MERGE clause
MERGE (node:Person:Actor {name: "Tom Hanks"})
ON CREATE SET node.created = datetime()
ON MATCH SET node.lastSeen = datetime()
RETURN node
apoc.merge.node.eager
CALL apoc.merge.node.eager(
  ["Person", "Actor"],
  {name: "Tom Hanks"},
  {created: datetime()},
  {lastSeen: datetime()}
)

apoc.merge.relationship

MERGE

Cypher’s MERGE clause
MATCH (p:Person {name: "Tom Hanks"})
MATCH (m:Movie {title:"You've Got Mail"})
MERGE (p)-[rel:ACTED_IN {roles:['Joe Fox']}]->(m)
ON CREATE SET rel.created = datetime()
ON MATCH SET rel.lastSeen = datetime()
RETURN rel
apoc.merge.relationship
MATCH (p:Person {name: "Tom Hanks"})
MATCH (m:Movie {title:"You've Got Mail"})
CALL apoc.merge.relationship(p, "ACTED_IN",
  {roles:['Joe Fox']},
  {created: datetime()},
  m,
  {lastSeen: datetime()}
)
YIELD rel
RETURN rel

Metadata (apoc.meta)

APOC Cypher equivalent Example Caveats

apoc.meta.cypher.isType Deprecated in Cypher 25

Type predicate expressions

Cypher’s type predicate expression
RETURN 1 IS :: NODE AS output
apoc.meta.cypher.isType
RETURN apoc.meta.cypher.isType(1, "NODE") AS output

apoc.meta.cypher.type Deprecated in Cypher 25

valueType function

Cypher’s valueType function
RETURN valueType(1) AS output
apoc.meta.cypher.type
RETURN apoc.meta.cypher.type(1) AS output

apoc.meta.graph

db.schema.visualization procedure

Neo4j’s db.schema.visualization procedure
CALL db.schema.visualization()
apoc.meta.graph
CALL apoc.meta.graph()

apoc.meta.nodes.count

count function

Cypher’s count function
MATCH (n:MyCountLabel|ThirdLabel)
RETURN count(n) AS count
apoc.meta.nodes.count
RETURN apoc.meta.nodes.count(['MyCountLabel', 'ThirdLabel']) AS count

Nodes (apoc.node, apoc.nodes)

APOC Cypher equivalent Example Caveats

apoc.node.degree Deprecated in Cypher 25

COUNT subquery

Cypher’s COUNT {}
MATCH (p:Person {name: "Michael"})
RETURN COUNT { (p)--() } AS output
apoc.node.degree
MATCH (p:Person {name: "Michael"})
RETURN apoc.node.degree(p) AS output

apoc.node.degree.in Deprecated in Cypher 25

COUNT subquery

Cypher’s COUNT {} and pattern matching
MATCH (p:Person {name: "Michael"})
RETURN COUNT { (p)<--() } AS output
apoc.node.degree.in
MATCH (p:Person {name: "Michael"})
RETURN apoc.node.degree.in(p) AS output

apoc.node.degree.out Deprecated in Cypher 25

COUNT subquery

Cypher’s COUNT {} and pattern matching
MATCH (p:Person {name: "Person1"})
RETURN COUNT { (p)-->() } AS output
apoc.node.degree.out
MATCH (p:Person {name: "Person1"})
RETURN apoc.node.degree.out(p) AS output

apoc.node.relationship.exists Deprecated in Cypher 25

EXISTS subquery

Cypher’s EXISTS {}
MATCH (p1:Person {name: "Michael"})
RETURN EXISTS {
    (p1)--()
} AS output
apoc.node.relationship.exists
MATCH (p1:Person {name: "Michael"})
RETURN apoc.node.relationship.exists(p1) AS output

apoc.node.relationships.exist Deprecated in Cypher 25

EXISTS subquery

Cypher’s EXISTS {}
MATCH (p1:Person {name: "Michael"})
RETURN EXISTS {
    (p1)--()
} AS output
apoc.node.relationship.exists
MATCH (p1:Person {name: "Michael"})
RETURN apoc.node.relationship.exists(p1) AS output

apoc.node.relationship.exists

COLLECT subquery and type function

Cypher’s COLLECT {} and type function
MATCH (p1:Person {name: "Person30"})
RETURN COLLECT {
    MATCH (p1)-[r]-()
    RETURN DISTINCT type(r)
} AS output
apoc.node.relationship.types
MATCH (p1:Person {name: "Person30"})
RETURN apoc.node.relationship.types(p1) AS output

apoc.nodes.connected

EXISTS subquery

Cypher’s EXISTS {} subquery
RETURN EXISTS { (p1:Person {name: "Michael"})--(p2:Person {name: "Person60"}) } AS output
apoc.nodes.connected
MATCH (p1:Person {name: "Michael"})
MATCH (p2:Person {name: "Person60"})
RETURN apoc.nodes.connected(p1, p2) AS output

apoc.nodes.delete Deprecated in Cypher 25

CALL subqueries in transactions

Cypher’s CALL {…​} IN TRANSACTIONS
MATCH (n:Student)
CALL (n) {
    DETACH DELETE n
} IN TRANSACTIONS OF 2 ROWS
RETURN count(n) AS value
apoc.nodes.delete
MATCH (n:Student)
WITH collect(n) AS nodes
CALL apoc.nodes.delete(nodes, 2)
YIELD value
RETURN value

apoc.nodes.get

id function

Using Cypher’s id
MATCH (node)
WHERE id(node) IN [3975, 3976, 3977]
RETURN node
apoc.nodes.get
CALL apoc.nodes.get([3975, 3976, 3977])

apoc.nodes.link

UNWIND

Using Cypher UNWIND
MATCH (e:Event)
WITH e ORDER BY e.date
WITH collect(e) AS events
UNWIND range(0, size(events) - 2) AS x
WITH x, events[x] AS node1, events[x+1] AS node2
CREATE (node1)-[:NEXT]->(node2)
RETURN count(*)
apoc.nodes.link
MATCH (e:Event)
WITH e ORDER BY e.date
WITH collect(e) AS events
CALL apoc.nodes.link(events, "NEXT")
RETURN count(*)

apoc.nodes.relationships.exist

EXISTS subquery

Cypher’s EXISTS {}
MATCH (p1:Person)
WHERE p1.name IN ["Michael", "Person30", "Person60"]
RETURN {
  node: p1,
  types: {
    `KNOWS>`: EXISTS { (p1)-[:KNOWS]->() },
    FOLLOWS: EXISTS { (p1)-[:FOLLOWS]-() }
  }
} AS output
apoc.nodes.relationships.exist
MATCH (p1:Person)
WHERE p1.name IN ["Michael", "Person30", "Person60"]
WITH collect(p1) AS people
UNWIND apoc.nodes.relationships.exist(people, "KNOWS>|FOLLOWS") AS output
RETURN output

apoc.nodes.rels Deprecated in Cypher 25

id function

Using Cypher’s id function
MATCH ()-[r]->()
WHERE id(r) = 499367
RETURN r
apoc.nodes.rels
CALL apoc.nodes.rels([499367]);

Paths (apoc.path)

APOC Cypher equivalent Example Caveats

apoc.path.elements

nodes, reduce, and relationships functions

Cypher’s nodes, relationships, and reduce functions
MATCH path = (club:Club)-[:IN_LEAGUE]->(league)-[:IN_COUNTRY]->(country)
WITH path, nodes(path) AS nodes, relationships(path) AS rels
RETURN path, reduce(acc=[nodes[0]], i IN range(0,size(rels)-1) | acc + rels[i] + nodes[i+1]) AS list
apoc.path.elements
MATCH path = (club:Club)-[:IN_LEAGUE]->(league)-[:IN_COUNTRY]->(country)
RETURN path, apoc.path.elements(path) AS list

Periodic execution (apoc.periodic)

APOC Cypher equivalent Example Caveats

apoc.periodic.iterate Deprecated in Cypher 25

CALL {…​} IN CONCURRENT TRANSACTIONS

Using Cypher CALL {…​} IN CONCURRENT TRANSACTIONS
MATCH (:Account)-[r:ASSOCIATED_WITH]->()
CALL (r) {
  SET r.status = CASE
    WHEN r.score > 90 THEN 'high'
    WHEN r.score > 50 THEN 'medium'
    ELSE 'low'
  END
} IN CONCURRENT TRANSACTIONS
apoc.periodic.iterate
CALL apoc.periodic.iterate(
  'MATCH (:Account)-[r:ASSOCIATED_WITH]->() RETURN id(r) AS id',
  'MATCH ()-[r]->() WHERE id(r) = id
   CALL apoc.do.case(
     [r.score > 90, "SET r.status = ''high'' RETURN r",
      r.score > 50, "SET r.status = ''medium'' RETURN r"],
     "SET r.status = ''low'' RETURN r",
     {r: r}
   ) YIELD value
   RETURN value',
  {batchSize: 10000, parallel: false, iterateList: true}
)

Refactoring (apoc.refactor)

APOC Cypher equivalent Example Caveats

apoc.refactor.categorize Deprecated in Cypher 25

Cypher’s dynamic labels
MATCH (p:Person)
CREATE (n:$(labels(p)))
SET n = properties(p)
WITH *
MATCH (p:Person)
RETURN DISTINCT p
apoc.refactor.cloneNodes
MATCH (p:Person)
WITH collect(p) AS people
CALL apoc.refactor.cloneNodes(people)
YIELD input
MATCH (p:Person)
RETURN DISTINCT p

apoc.refactor.cloneNodes

Cypher’s dynamic labels
MATCH (p:Person)
CREATE (n:$(labels(p)))
SET n = properties(p)
WITH *
MATCH (p:Person)
RETURN DISTINCT p
apoc.refactor.cloneNodes
MATCH (p:Person)
WITH collect(p) AS people
CALL apoc.refactor.cloneNodes(people)
YIELD input
MATCH (p:Person)
RETURN DISTINCT p

apoc.refactor.collapseNode

Using Cypher
MATCH (flight:Flight {number: "BA001"})
CALL (flight) {
    MATCH p=(a)-[]-(f)-[]-(b)
    WITH p, a, f, b LIMIT 1
    CREATE (a)-[r:CONNECTED_TO]->(b)
    SET r = properties(f)
    DETACH DELETE f
    RETURN r AS newRel
}
RETURN newRel
apoc.refactor.collapseNode
MATCH (flight:Flight {number: "BA001"})
CALL apoc.refactor.collapseNode([flight],'CONNECTED_TO')
YIELD input, output
RETURN input, output

apoc.refactor.extractNode

Using Cypher
MATCH (:Airport)-[rel:FLIGHT]->(:Airport)
CALL (rel) {
    WITH startNode(rel) AS startNode, endNode(rel) AS endNode, rel
    CREATE (startNode)-[:IN]->(f:Flight)-[:OUT]->(endNode)
    SET f = properties(rel)
    DELETE rel
}
RETURN 0 AS input, newNode AS output
apoc.refactor.extractNode
MATCH (:Airport)-[rel:FLIGHT]->(:Airport)
WITH collect(rel) AS rels
CALL apoc.refactor.extractNode(rels,['Flight'],'OUT','IN')
YIELD input, output
RETURN input, output

apoc.refactor.from

Using Cypher dynamic labels
MATCH (michael:Person {name: "Michael"})
MATCH ()-[rel:FOLLOWS]->()
CALL (rel, michael) {
    WITH id(rel) AS oldId, properties(rel) AS relProps, type(rel) AS relType, endNode(rel) AS endNode
    DELETE rel
    MERGE (michael)-[newRel:$(relType)]->(endNode)
    SET newRel = relProps
    RETURN oldId AS oldId, newRel AS newRel
}
RETURN oldId, newRel
apoc.refactor.from
MATCH (michael:Person {name: "Michael"})
MATCH ()-[rel:FOLLOWS]->()
CALL apoc.refactor.from(rel, michael, { failOnErrors: true })
YIELD input, output
RETURN input, output

apoc.refactor.invert

Using Cypher’s dynamic labels
MATCH (startNode)-[rel:FOLLOWS]->(endNode)
CALL (*) {
    WITH id(rel) AS oldId, properties(rel) AS relProps, type(rel) AS relType
    DELETE rel
    MERGE (startNode)<-[newRel:$(relType)]-(endNode)
    SET newRel = relProps
    RETURN oldId AS oldId, newRel AS newRel
}
RETURN oldId, newRel;
apoc.refactor.invert
MATCH ()-[rel:FOLLOWS]->()
CALL apoc.refactor.invert(rel, { failOnErrors = true })
YIELD input, output
RETURN input, output

apoc.refactor.rename.label Deprecated in Cypher 25

Using Cypher’s SET
MATCH (person:Engineer)
WHERE person.name IN ["Mark", "Jennifer", "Michael"]
SET person:DevRel
REMOVE person:Engineer
RETURN count(*) AS total
apoc.refactor.rename.label
MATCH (person:Engineer)
WHERE person.name IN ["Mark", "Jennifer", "Michael"]
WITH collect(person) AS people
CALL apoc.refactor.rename.label("Engineer", "DevRel", people)
YIELD total
RETURN total

apoc.refactor.rename.nodeProperty Deprecated in Cypher 25

Using Cypher’s REMOVE
MATCH (person:DevRel)
SET person.location = person.city
REMOVE person.city
RETURN count(*) AS total
apoc.refactor.rename.nodeProperty
MATCH (person:DevRel)
WITH collect(person) AS people
CALL apoc.refactor.rename.nodeProperty("city", "location", people)
YIELD total
RETURN total

apoc.refactor.rename.type Deprecated in Cypher 25

Using Cypher
MATCH (a:Engineer {name: "Jim"})-[rel:COLLEAGUES]->(b:Engineer {name: "Alistair"})
MERGE (a)-[r:FROLLEAGUES]->(b)
SET r = properties(rel)
WITH rel, r
DELETE rel
RETURN count(*) AS count
apoc.refactor.rename.type
MATCH (:Engineer {name: "Jim"})-[rel]->(:Engineer {name: "Alistair"})
WITH collect(rel) AS rels
CALL apoc.refactor.rename.type("COLLEAGUES", "FROLLEAGUES", rels)
YIELD batches
RETURN count(*) AS count

apoc.refactor.rename.typeProperty Deprecated in Cypher 25

Using Cypher’s REMOVE
MATCH ()-[rel]->()
SET rel.from = rel.since
REMOVE rel.since
RETURN count(*) AS total
apoc.refactor.rename.typeProperty
MATCH ()-[rel]->()
WITH collect(rel) AS rels
CALL apoc.refactor.rename.typeProperty("since", "from", rels)
YIELD total
RETURN total

apoc.refactor.setType Deprecated in Cypher 25

Using Cypher
MATCH (f:Foo)-[rel:FOOBAR]->(b:Bar)
CREATE (f)-[r:`NEW-TYPE`]->(b)
SET r = properties(rel)
DELETE rel
RETURN id(r), type(r)
apoc.refactor.setType
MATCH (f:Foo)-[rel:FOOBAR]->(b:Bar)
CALL apoc.refactor.setType(rel, 'NEW-TYPE')
YIELD input, output
RETURN input, output

Temporals (apoc.temporal)

APOC Cypher equivalent Example Caveats

apoc.temporal.format Deprecated in Cypher 25

format function

Cypher’s format function
RETURN format(date(), 'yyyy-MM-dd') AS output
apoc.temporal.format
RETURN apoc.temporal.format( date(), 'yyyy-MM-dd') AS output

apoc.temporal.formatDuration Deprecated in Cypher 25

format function

Cypher’s format function
RETURN format(duration({seconds: 6000}), "hh") AS output
apoc.temporal.formatDuration
RETURN apoc.temporal.formatDuration(duration({seconds: 6000}), "hour") AS output

apoc.temporal.toZonedTemporal Deprecated in Cypher 25

Corresponding temporal type constructor, for example the datetime function.

Cypher’s datetime function
RETURN datetime('2012-12-23 23:59:59',"yyyy-MM-dd HH:mm:ss") AS output
apoc.temporal.toZonedTemporal
RETURN apoc.temporal.toZonedTemporal('2012-12-23 23:59:59',"yyyy-MM-dd HH:mm:ss") AS output

Texts (apoc.text)

APOC Cypher equivalent Example Caveats

apoc.text.format

String Interpolation

Cypher’s string interpolation
WITH "Bloom" AS bloom
RETURN s"Neo4j { bloom }" AS output
apoc.text.format
WITH "Bloom" AS bloom
RETURN apoc.text.format("Neo4j %s", [bloom]) AS output

apoc.text.indexOf Deprecated in Cypher 25

string.indexOf function

Cypher’s string.indexOf function
RETURN string.indexOf("Hello World", 'Hello') AS output
apoc.text.indexOf
RETURN apoc.text.indexOf("Hello World", 'Hello') AS output

apoc.text.join Deprecated in Cypher 25

string.join function

Cypher’s string.join function
RETURN string.join(['Hello', 'World'], ' ') AS output
apoc.text.join
RETURN apoc.text.join(['Hello', 'World'], ' ') AS output

apoc.text.replace Deprecated in Cypher 25

string.regexReplace function

Cypher’s string.regexReplace
RETURN string.regexReplace('Hello World!', '[^a-zA-Z]', '') AS output
apoc.text.replace
RETURN apoc.text.replace('Hello World!', '[^a-zA-Z]', '') AS output