Giter Site home page Giter Site logo

neo4j-contrib / neo4j-script-procedures Goto Github PK

View Code? Open in Web Editor NEW
18.0 6.0 4.0 20 KB

Neo4j Procedures to declare, store and run Javascript, Python, R, Ruby based procedures

License: Apache License 2.0

Java 100.00%
neo4j cypher cypher-query-language user-defined-functions javascript java-scripting script-engine stored-procedures graph-database

neo4j-script-procedures's Introduction

Neo4j Script Procedures

Build Status

This project demonstrates how to create dynamic procedures and functions on top of Neo4jโ€™s built in infrastructure.

You can create JavaScript functions in your database that can be later run using the 'nashorn' engine.

This project requires Neo4j 3.x

Installation

  1. Download the jar from the latest release

  2. Copy it into your $NEO4J_HOME/plugins directory.

  3. Add dbms.security.procedures.unrestricted=scripts.* to $NEO4J_HOME/conf/neo4j.conf

  4. Restart your server.

Operations

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); }

Building it yourself

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.

License

Apache License V2, see LICENSE

neo4j-script-procedures's People

Contributors

fbiville avatar jexp avatar objectundefined avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

neo4j-script-procedures's Issues

Add support for python, R, ruby, js via graalvm-polyglot

See github.com/moxious/magnolia.

http://www.graalvm.org/docs/reference-manual/polyglot/

/cc @moxious

// gu install ruby python R 
// groovy PolyTest1.groovy 
@Grab("org.graalvm.sdk:graal-sdk:1.0.0-rc9")

import org.graalvm.polyglot.*

context = Context.newBuilder().allowAllAccess(true).build()
context.eval("js", "print('Hello JavaScript!');")
context.eval("R", "print('Hello R!');");
context.eval("ruby", "puts 'Hello Ruby!'");
context.eval("python", "print('Hello Python!')");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.