About Michael Hunger

Posts by Michael Hunger:


Fullstack JavaScript – Neo4j Script Procedures

on Apr 1, 2017 in cypher, neo4j

Imagine, being a fullstack JavaScript developer and not just using the language in the frontend, middleware or backend but also to create your user-defined procedures and functions in the database.

Several other databases support a similar approach for views and user defined extensions, and now you can do it with Neo4j too.

Already early last year, Neo4j’s user defined procedures were still in their infancy.
I had just written an article about the Javas JavaScript engine “Nashorn”.

So naturally I experimented with using procedures to dynamically create and run JavaScript functions.

The function mapping is stored in Neo4j’s graph properties.

You could create JavaScript functions with a name and body and then later call them by name and passing parameters along.

CALL scripts.function('users', '
function users(name) {
  return collection(db.findNodes(label("User"),'lastname',name));

CALL scripts.run('users','Anderson') YIELD value as user;

// or call as function, returns a list
RETURN scripts.run('users','Smith');

That worked all quite well, but I didn’t find the time to turn that into a proper project.

Later in the year I got some feature and pull requests on the APOC procedure library to add such functions.

As there are some concerns esp. from corporate users about scripting support, I pulled my work into a separate project: Neo4j Script Procedures

So, when I came across this tweet, it reminded me of wanting to update the project.

I thought it was a good opportunity to upgrade and release the project.

So, now you can try to run JavaScript functions from Neo4j’s Cypher by grabbing the jar-file from the latest release.

Just put it into $NEO4J_HOME/plugins and restart your server.

Note: In Neo4j Community Desktop, there is a directory chooser on the “Options” for the plugins directory)

The of neo4j-script-procedures release does not support Neo4j 3.1.2 as there are some incompatibilities with procedures creating new property-names.
It should work with 3.1.0, 3.1.1 or 3.1.3 though.

Let me know what you think and how we can improve this little useful library, please raise issues on the repository for feedback and problems.

Tags: , ,


Creating a Neo4j Example Graph with the Arrows Tool

on Mar 21, 2017 in cypher, import

Some years ago my colleague Alistair Jones created a neat little tool in JavaScript to edit and render example graphs in a consistent way.

It is aptly named Arrows and you can find it here: http://www.apcjones.com/arrows

We mostly use it for presentations, but also to show data models for Neo4j GraphGists and Neo4j Browser Guides.
Because it also [...]


Academy Awards (Oscars) from Kaggle to Neo4j

on Mar 9, 2017 in cypher, import, neo4j

pre {
line-height: normal;
table {
margin: 10px;
th, td {
border-bottom: 1px solid black;
th {
background-color: #ddd;
img {

Table of Contents

Install Neo4j
Find the data as CSV
Importing the Data
Some Fun Queries
Part 2: Full Import from Kaggle
More Queries

Most Oscars
Most different Awards
Which Countries got the most [...]


5 Tips & Tricks for Fast Batched Updates of Graph Structures with Neo4j and Cypher

on Mar 2, 2017 in Uncategorized, cypher, import, neo4j

Inefficient Solutions
Better Approach

UNWIND to the Rescue
Overall Syntax Structure


Create node with properties
MERGE node with properties
Node lookup and MERGE/CREATE relationship between with properties
Lookup by id, or even list of ids

Faster, Better, Further: All the tricks

Update of existing nodes by id
Update of existing relationships by id

Conditional Data Creation
Utilizing APOC Procedures

Creating Nodes and Relationships dynamically
Batched Transactions
Creating / Updating Maps [...]


The Reddit Meme Graph with Neo4j

on Feb 25, 2017 in cypher, import

pre {
line-height: normal;
img {

Saturday night after not enough drinks, I came across these tweets by @LeFloatingGhost.

This definitely looks like a meme graph.

We can do that too


User Defined Functions in Neo4j 3.1.0-M10

on Oct 6, 2016 in apoc, cypher

Neo4j 3.1 brings some really neat improvements in Cypher alongside other cool features

I already demonstrated the – GraphQL inspired – map projections and pattern comprehensions in my last blog post.

User Defined Procedures

In the 3.0 release my personal favorite was user defined procedures which can be implemented using Neo4j’s Java API and called directly from Cypher.
You [...]


Neo4j 3.0 Stored Procedures

on Feb 29, 2016 in cypher, java

One of the many exciting features of Neo4j 3.0 are “Stored Procedures” that, unlike the existing Neo4j-Server extensions are directly callable from Cypher.

At the time of this writing it is only possible to call them in a stand-alone statement with CALL package.procedure(params)
but the plan is to make them a fully integrated part of Cypher statements.
Either [...]


Using XRebel 2 with Neo4j

on May 5, 2015 in neo4j

At Spring.IO in Barcelona I met my pal Oleg from ZeroTurnaround and we looked at how the new XRebel 2
integrates with Neo4j, especially with the remote access using the transactional Cypher http-endpoint.

As you probably know, Neo4j currently offers a remoting API based on HTTP requests (a new binary protocol is in development).

Our JDBC driver utilizes [...]


Neo4j Server Extension for Single Page Experiments

on Apr 24, 2015 in neo4j, server

Sometimes you have a nice dataset in Neo4j and you’d want to provide a self-contained way of quickly exposing it to the outside world without a multi-tier setup.

So for experiments and proofs of concepts it would be helpful to be able to extend Neo4j Browser to accomodate new types of frames and commands.
Unfortunately we’re not [...]


How To: Neo4j Data Import – Minimal Example

on Apr 18, 2015 in import, neo4j

We want to import data into Neo4j, there are too many resources with a lot of information which makes it confusing.
Here is the minimal thing you need to know.

Imagine the data coming from the export of a relational or legacy system, just plain CSV files without headers (this time).





Graph Model

Our graph Model would be very [...]

Copyright © 2007-2017 Better Software Development All rights reserved.
Multi v1.4.5 a child of the Desk Mess Mirrored v1.4.6 theme from BuyNowShop.com.