-
Download the jar from the latest release
-
Copy it into your
$NEO4J_HOME/plugins
directory. -
Add
dbms.security.procedures.unrestricted=scripts.*
to$NEO4J_HOME/conf/neo4j.conf
-
Restart your server.
The operations are:
create function
CALL scripts.function({name}, {code})
{"name" : "users",
"code" : "function users() { return collection(db.findNodes(label('User'))) }"}
run function as procedure
CALL scripts.run({name}[, {params}])
CALL scripts.run('users', null)
CALL scripts.run('users')
-> returns one user per row
run function as function
RETURN scripts.run({name}[, {params}])
RETURN scripts.run('users', null) as users
or
RETURN scripts.run('users') as users
-> returns a list of users
list functions
CALL scripts.list()
helper functions
function label(s) { return org.neo4j.graphdb.Label.label(s); }
function type(s) { return org.neo4j.graphdb.RelationshipType.withName(s); }
function collection(it) { r=[]; while (it.hasNext()) r.push(it.next()); return Java.to(r); }
This project uses maven, to build a jar-file with the procedure in this project, simply package the project with maven:
mvn clean package
This will produce a jar-file,target/neo4j-script-procedures-*-SNAPSHOT.jar
, that can be copied in the $NEO4J_HOME/plugins
directory of your Neo4j instance.