Introduction

This introduction contains a brief history of the APOC Library, an example of an APOC procedure used within a Cypher statement, and a note about the Neo4j memory tracker.

History

For a brief introduction to the history and development of the APOC Library by Michael Hunger, Senior Director of User Innovation at Neo4j, watch this short video:

Neo4j 3.x introduced the concept of user-defined procedures and functions. These procedures and functions are implemented in Java and can be deployed into a Neo4j instance, and then be called from Cypher directly.

There are over 400 different procedures and functions in the APOC library. Their purpose is to increase functionality in areas such as data integration, graph algorithms and data conversion.

APOC Name History

APOC was the first bundled Package Of Component for Neo4j in 2009. It stands for "Awesome Procedures On Cypher".

Apoc was also the technician and driver on board of the Nebuchadnezzar in the first Matrix movie. He was killed by another character called Cypher.

APOC is available in Neo4j AuraDB. For a full list of the APOC procedures and functions supported by Aura, go to the Aura page for APOC. APOC is also available in Neo4j Sandbox, Docker, and Neo4j Desktop. Finally, the APOC library can be made available in self-hosted databases by installing the APOC jar.

A full list of all the functions and procedures available in the APOC library can be found in Procedures & Functions.

As of Neo4j version 5.0, APOC has been split into separate repositories, one being the main, officially supported, APOC Library. The other belonging to APOC Extended. This documentation handles the officially supported part of APOC.

Example

User defined functions can be used in any expression or predicate, similar to built-in functions.

Procedures can be called stand-alone using CALL procedure.name();

Procedures can also be integrated into Cypher statements.

The below example demonstrates how the procedure apoc.load.json can be integrated in a Cypher statement:

Load JSON example
WITH 'https://raw.githubusercontent.com/neo4j/apoc/5.0/src/test/resources/person.json' AS url

CALL apoc.load.json(url) YIELD value as person

MERGE (p:Person {name: person.name})
   ON CREATE SET p.age = person.age, p.children = size(person.children)

For further examples using specific APOC procedures and functions, please see the Procedures & Functions.

Note about the Neo4j memory tracker

Before using the APOC library, it is important to note that APOC procedures are not detected by the Neo4j Memory Tracker. They will, therefore, not terminate if they exceed the available memory in the database.

For example, the procedure apoc.path.expand will not stop if dbms.memory.transaction.database_max_size is reached.

Moreover, it is not possible to use the SHOW TRANSACTIONS YIELD currentQuery, estimatedUsedHeapMemory command to monitor the memory usage of a query.

In order to avoid Java Heap Space errors, the APOC procedures should therefore be used carefully.