Procedures are the preferred means for extending Neo4j. It allows Neo4j to be extended by writing custom code which can be invoked directly from Cypher.
To know more about how to write and call procedures, please visit the Neo4j procedures documentation.
Stored procedures are available in 3.0.0 or higher versions of Neo4j. You can check your Neo4j version if you navigate to the Overview page of your database.
Follow these instructions to add a stored procedure to your database:
- Navigate to the Extensions tab of your database dashboard, and select New stored procedure from the New extension drop-down menu.
- Name your stored procedure in order to be able to identify it afterward.
- Select the .jar file from your local path and click on Add stored procedure. There is a size limit of 100MB for Hobby and Standard databases and 500MB for Performance and higher.
- Do not close the browser window! The upload will stop if you close your browser. If the upload fails, you can click on the Retry button to start it again.
- When the upload completes successfully, you will see a new row in your Extensions list with the status ENABLED - PENDING.
- Before the stored procedure can be available for use, it is necessary to restart the database. To perform this operation, click on the Apply changes button.
- A new window will show you a list of the changes you are going to perform. Please review them and click on Apply changes.
You can enable/disable your stored procedures in your extensions list by clicking on the appropriate button next to each stored procedure. Remember that you should click on Apply changes button to confirm all of these changes.
Once the changes are applied, you will see the final status (ENABLED or DISABLED) in the list.
You can enable/disable more than one extension at once. Click on the Enable/Disable button of the different extensions.
APOC is a generally usable library of procedures by Michael Hunger that covers different aspects that are currently not available on Cypher. It contains more than 200 procedures of different areas. You can read more about it here.
If you want to check that APOC is available in your database, you can use the following built-in procedure and get a list:
CALL dbms.procedures() YIELD name RETURN head(split(name,".")) as package, count(*), collect(name) as procedures;
To remove a stored procedure
- Navigate to the Extensions tab of your database dashboard
- Click on the Disable button next to the stored procedure you wish to remove.
- Once the stored procedure is disabled, you can click on Remove to fully remove the stored procedure.
Only disabled stored procedures can be removed. Make sure you disable the procedure before attempting to remove it. You can disable the procedure by clicking on the Disable button.
This action cannot be undone and will delete your stored procedure permanently.