- Notifications
You must be signed in to change notification settings - Fork499
Awesome Procedures On Cypher for Neo4j - codenamed "apoc" If you like it, please ★ above ⇧
License
neo4j-contrib/neo4j-apoc-procedures
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Neo4j 3.x introduced the concept of user-defined procedures and functions.Those are custom implementations of certain functionality, that can’t be (easily) expressed in Cypher itself.They 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 450) procedures and functions to help with many different tasks in areas like data integration, graph algorithms or data conversion.
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 bundledA Package Of Component for Neo4j in 2009.
APOC also stands for "Awesome Procedures On Cypher"
APOC Full can be installed withNeo4j Desktop, after creating your database, by going to theManage
screen, and then thePlugins
tab.ClickInstall
in the APOC box and wait until you see a green check mark near "APOC".
Please provide feedback and report bugs asGitHub issues or join theNeo4j Community Forum and ask with the APOC tag.
User definedFunctions can be used inany expression or predicate, just like built-in functions.
Procedures can be called stand-alone withCALL 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/4.4/core/src/test/resources/person.json'ASurlCALLapoc.load.json(url)YIELDvalueaspersonMERGE (p:Person{name:person.name})ONCREATESETp.age=person.age,p.children=size(person.children)
All included procedures are listed in theoverview in the documentation and detailed in subsequent sections.
See theAPOC User Guide for documentation of each of the major features of the library, including data import/export, graph refactoring, data conversion, and more.
To call procedures correctly, you need to know their parameter names, types and positions.And for YIELDing their results, you have to know the output column names and types.
INFO:The signatures are shown in error messages, if you use a procedure incorrectly.
You can see the procedures signature in the output ofCALL apoc.help("name")
CALLapoc.help("dijkstra")
The signature is alwaysname : : TYPE
, so in this case:
apoc.algo.dijkstra (startNode :: NODE?, endNode :: NODE?, relationshipTypesAndDirections :: STRING?, weightPropertyName :: STRING?):: (path :: PATH?, weight :: FLOAT?)
Name | Type |
---|---|
Procedure Parameters | |
|
|
|
|
|
|
|
|
Output Return Columns | |
|
|
|
|
Since APOC relies on Neo4j’s internal APIs you need to use thematching APOC version for your Neo4j installaton.Make sure that thefirst two version numbers match between Neo4j and APOC.
Go tothe latest release forNeo4j version 4.4 and download the binary jar to place into your$NEO4J_HOME/plugins
folder.
You can findall releases here.
Warning | For security reasons, procedures and functions that use internal APIs are disabled by default.Loading and enabling APOC procedures and functions can be configured using the Neo4j config file.For more details, seethe APOC installation documentation. |
Since APOC relies in some places on Neo4j’s internal APIs you need to use the right APOC version for your Neo4j installaton.
APOC uses a 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 |
---|---|
4.4.0 (4.3.x) | |
4.3.7 (4.3.x) | |
4.2.11 (4.2.x) | |
4.1.11 (4.1.x) | |
4.0.12 (4.0.x) | |
3.5.30 (3.5.x) | |
3.4.18 (3.4.x) | |
3.3.9 (3.3.x) | |
3.2.14 (3.2.x) | |
3.1.9 (3.1.x) | |
3.0.12 (3.0.x) | |
3.5.0-beta01 | |
3.4.5 | |
3.3.5 | |
3.2.3 | |
3.1.5 |
APOC Full can be used with theNeo4j Docker image via theNEO4JLABS_PLUGINS
environment variable.If we use this environment variable, the APOC plugin will be downloaded and configured at runtime.
Note | This feature is intended to facilitate using APOC in development environments, but it is not recommended for use in production environments. |
docker run \ -p 7474:7474 -p 7687:7687 \ -v$PWD/data:/data -v$PWD/plugins:/plugins \ --name neo4j-apoc \ -e NEO4J_apoc_export_file_enabled=true \ -e NEO4J_apoc_import_file_enabled=true \ -e NEO4J_apoc_import_file_use__neo4j__config=true \ -e NEO4JLABS_PLUGINS=\[\"apoc\"\] \ neo4j:4.0
We should see the following two lines in the output after running this command:
Fetching versions.json for Plugin 'apoc' from https://neo4j-contrib.github.io/neo4j-apoc-procedures/versions.jsonInstalling Plugin 'apoc' from https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.4.0.40/4.4.0.40-all.jar to /plugins/apoc.jar
In a production environment we should download the APOC release matching our Neo4j version and, copy it to a local folder, and supply it as a data volume mounted at/plugins
.
plugins
directory and then mounts that folder to the Neo4j Docker containermkdir pluginspushd pluginswget https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/4.4.0.40/apoc-4.4.0.40-all.jarpopddocker run --rm -e NEO4J_AUTH=none -p 7474:7474 -v$PWD/plugins:/plugins -p 7687:7687 neo4j:4.4
If you want to pass custom apoc config to your Docker instance, you can use environment variables, like here:
docker run \ -p 7474:7474 -p 7687:7687 \ -v$PWD/data:/data -v$PWD/plugins:/plugins \ --name neo4j-apoc \ -e NEO4J_apoc_export_file_enabled=true \ -e NEO4J_apoc_import_file_enabled=true \ -e NEO4J_apoc_import_file_use__neo4j__config=true \ neo4j
git clone https://github.com/neo4j-contrib/neo4j-apoc-procedurescd neo4j-apoc-procedures./gradlew shadowcp build/full/libs/apoc-<version>-all.jar $NEO4J_HOME/plugins/$NEO4J_HOME/bin/neo4j restart
A full build including running the tests can be run by./gradlew build
.
./gradlew spotlessApply
To apply thespotless code-style, run the above gradle command, this will remove all unused imports
About
Awesome Procedures On Cypher for Neo4j - codenamed "apoc" If you like it, please ★ above ⇧
Topics
Resources
License
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.