Introduction
Note
|
Go here for documentation for APOC version 3.1.x |

Neo4j 3.0 introduced the concept of user defined procedures. Those are custom implementations of certain functionality, that can’t be (easily) expressed in Cypher itself. Those procedures are implemented in Java and can be easily deployed into your Neo4j instance, and then be called from Cypher directly.
The APOC library consists of many (about 300) procedures to help with many different tasks in areas like data integration, graph algorithms or data conversion.
License
Apache License 2.0
"APOC" Name history
Apoc was the technician and driver on board of the Nebuchadnezzar in the Matrix movie. He was killed by Cypher.
APOC was also the first bundled A Package Of Components for Neo4j in 2009.
APOC also stands for "Awesome Procedures On Cypher"
Installation
Download latest release
to find the latest release and download the binary jar to place into your $NEO4J_HOME/plugins
folder.
Version Compatibility Matrix
Since APOC relies in some places on Neo4j’s internal APIs you need to use the right APOC version for your Neo4j installaton.
Any version to be released after 1.1.0 will use a different, consistent versioning scheme: <neo4j-version>.<apoc>
version. The trailing <apoc>
part of the version number will be incremented with every apoc release.
apoc version |
neo4j version |
3.1.0.3 |
3.1.0 (3.1.x) |
3.0.8.4 |
3.0.8 (3.0.x) |
3.0.4.3 |
3.0.4 (3.0.x) |
1.1.0 |
3.0.0 - 3.0.3 |
1.0.0 |
3.0.0 - 3.0.3 |
Installation
>>>>>>> d3418dd... fixes #156: implement automatic tracking of manual index changesusing APOC with Neo4j Docker image
The Neo4j Docker image allows to supply a volume for the /plugins
folder. Download the APOC release fitting your Neo4j version to local folder plugins
and provide it as a data volume:
mkdir plugins
pushd plugins
wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.0.8.4/apoc-3.0.8.4-all.jar
popd
docker run --rm -e NEO4J_AUTH=none -p 7474:7474 -v $PWD/plugins:/plugins -p 7687:7687 neo4j:3.0.8
Build & install the current development branch from source
=======Go to http://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/3.0.8.4
to find the latest release and download the binary jar to place into your $NEO4J_HOME/plugins
folder.
Version Compatibility Matrix
Since APOC relies in some places on Neo4j’s internal APIs you need to use the right APOC version for your Neo4j installaton.
Any version to be released after 1.1.0 will use a different, consistent versioning scheme: <neo4j-version>.<apoc>
version. The trailing <apoc>
part of the version number will be incremented with every apoc release.
apoc version |
neo4j version |
3.1.0.3 |
3.1.0 (3.1.x) |
3.0.8.4 |
3.0.8 (3.0.x) |
3.0.4.3 |
3.0.4 (3.0.x) |
1.1.0 |
3.0.0 - 3.0.3 |
1.0.0 |
3.0.0 - 3.0.3 |
using APOC with Neo4j Docker image
The Neo4j Docker image allows to supply a volume for the /plugins
folder. Download the APOC release fitting your Neo4j version to local folder plugins
and provide it as a data volume:
mkdir plugins
pushd plugins
wget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.0.8.4/apoc-3.0.0.4-all.jar
popd
docker run --rm -e NEO4J_AUTH=none -p 7474:7474 -v $PWD/plugins:/plugins -p 7687:7687 neo4j:3.0.8
Build & install the current development branch from source
>>>>>>> d3418dd... fixes #156: implement automatic tracking of manual index changesgit clone http://github.com/neo4j-contrib/neo4j-apoc-procedures cd neo4j-apoc-procedures ./gradlew shadow cp build/libs/apoc-<version>-SNAPSHOT-all.jar $NEO4J_HOME/plugins/ $NEO4J_HOME/bin/neo4j restart
A full build including running the tests can be run by ./gradlew build
.
Calling Procedures & Functions within Cypher
User defined Functions can be used in any expression or predicate, just like built-in functions.
Procedures can be called stand-alone with CALL procedure.name();
But you can also integrate them into your Cypher statements which makes them so much more powerful.
WITH 'https://raw.githubusercontent.com/neo4j-contrib/neo4j-apoc-procedures/master/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)
Procedure & Function Signatures
To call procedures correctly, you need to know their parameter names, types and positions. And for YIELDing their results the output column name and type.
You can see the procedures signature in the output of CALL dbms.procedures()
(The same applies for functions with CALL dbms.functions()
)
CALL dbms.procedures() YIELD name, signature
WITH * WHERE name STARTS WITH 'apoc.algo.dijkstra'
RETURN name, signature
The signature is always name : : TYPE
, so in this case:
apoc.algo.dijkstra (startNode :: NODE?, endNode :: NODE?, relationshipTypesAndDirections :: STRING?, weightPropertyName :: STRING?) :: (path :: PATH?, weight :: FLOAT?)
Parameters:
Name | Type |
---|---|
Procedure Parameters |
|
|
|
|
|
|
|
|
|
Output Return Columns |
|
|
|
|
|