Neo4j customized code
User-defined procedures and user-defined functions are mechanisms that enable you to extend Neo4j by writing customized code, which can be invoked directly from Cypher. This is the preferred means for extending Neo4j.
Examples of use cases for procedures and functions are:
-
To provide access to functionality that is not available in Cypher.
-
To provide access to third-party systems.
-
To perform graph-global operations, such as counting connected components or finding dense nodes.
-
To express a procedural operation that is difficult to express declaratively with Cypher.
Procedures and functions are written in Java and compiled into JAR files. They are deployed to the database by dropping that JAR file into the plugins directory on each standalone or clustered server. For the location of the plugins directory, refer to Operations Manual → Default file locations. The database must be restarted on each server to pick up new procedures and functions.
Procedures and functions can take arguments and return results. In addition, procedures can perform write operations on the database.
Type | Description | Syntax | Read/Write | Cardinality |
---|---|---|---|---|
|
For each row, the procedure takes parameters and returns multiple results. |
|
Update allowed. |
Changes cardinality similarly to a |
|
For each row, the function takes parameters and returns a single result. |
|
Read-only. |
Maintains cardinality, one for one. |
|
Consumes many rows and produces an aggregated result. |
|
Read-only. |
Reduces cardinality, many down to one. |
Neo4j also comes bundled with a number of built-in procedures and functions.
The available built-in procedures vary depending on edition and mode, as described in Operations Manual → Procedures.
Running SHOW PROCEDURES
displays the full list of procedures available in your Neo4j DBMS, including user-defined procedures.
The built-in functions are described in Cypher Manual → Functions.
Running SHOW FUNCTIONS
displays the full list of all the functions available in your Neo4j DBMS, including user-defined functions.