If you are interested in writing your own custom procedure, Neo4j provides a Java API for this. In a Maven project, you will have to include the following dependency:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>${neo4j.version}</version>
<scope>provided</scope>
</dependency>
A user-defined function that simply multiplies two numbers together can be implemented with the following piece of code:
@UserFunction
@Description("packt.multiply(value, value)")
public Double multiply(
@Name("number1") Double number1,
@Name("number2") Double number2
) {
if (number1 == null || number2 == null) {
return null;
}
return number1 * number2;
}
Let's break down this code:
- The @UserFunction annotation declares a user-defined function. Similarly, procedures can be declared with the @Procedure annotation...