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 click on the New stored procedure button in the dropdown menu New extension.
- Name your stored procedure in order to be able to identify it afterwards.
- Select the .jar file from your local path and click on Add stored procedure. There is a size limit of 100MB.
- 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 here.
If you want to check that APOC are 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 your stored procedures, navigate to the Extensions tab of your database dashboard, and just click on the Remove link next to 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.