Over a million developers have joined DZone.

Integrate Neo4j with Apache Zeppelin

DZone's Guide to

Integrate Neo4j with Apache Zeppelin

Here we are going to be adding Neo4J to Apache Zeppelin and using to for data analytics with graphs.

· Big Data Zone
Free Resource

Learn best practices according to DataOps. Download the free O'Reilly eBook on building a modern Big Data platform.

This autumn I’ve attended a couple of conferences. It’s always interesting to learn about new tools popping up. One that took my attention is Apache Zeppelin. Zeppelin is a notebook style application focussing on data analytics. I’ll show in this article how Zeppelin can be used to access data residing in your favorite graph database Neo4j.

Apache Zeppelin Screenshot

I consider Zeppelin becoming a great piece in my toolbox when it comes to doing proof of concept projects. Most of this PoC work is focussing on graph database modeling and importing data from any kinds of formats. Of course the real value is not in having data in a graph database on its own but instead doing “something” with it. In a lot of cases visualization is the “something” and finally proves the value of the concept. Since my javascript skills are rather poor compared to good old java, I typically spend more time than needed to work on visualizations. With Zeppelin this hopefully increases my productivity since basic visualizations come out of the box.

Downloading & Installing Zeppelin

Download the most recent binary Zeppelin package with all interpreters included from https://zeppelin.apache.org/download.html and extract the tgz archive. Start up Zeppelin using bin/zeppelin-daemon.sh start and connect your webbrowser to http://localhost:8080 zeppelin start page

Connect Zeppelin to Neo4j

Bring up a Neo4j (>= 3.0) instance, for simplicity we’ll run it on localhost as well, e.g. using docker: docker run --rm -p 7474:7474 -p 7687:7687 neo4j:3.0.7-enterprise. Be sure to set up a password – I’m using the most famous one “123” in this example – choose a better one for your own instances.

To configure a Neo4j datasource go to the dropdown nearby “anonymous” in the title bar, go to “Interpreter”.bildschirmfoto-vom-2016-11-15-15-29-04

Use the “+Create” button on the upper right corner. First select “jdbc” in interpreter group and fill out the values according to this screenshot – you can delete the other options.

zeppelin interpreter config for neo4j

Please note that you don’t need to download the neo4j-jdbc driver manually, Zeppelin will fetch it from maven central if you supply org.neo4j:neo4j-jdbc-bolt:3.0.1 for artifact.

Setting up a Zeppelin Note Using Neo4j

Now it’s time to access Neo4j from a Zeppelin note. Create a new note by choosing “Create new note” from the “Notebook” drop down at the header line. You need to go to the gear-wheel icon on the top right “Interpreter bindings”. Be sure to enable “neo4j %jdbc”: setting up interpreter bindings

When done, you can run a Cypher query using the following notation:

%neo4j match (actor:Person)-[:ACTED_IN]->(m:Movie)  with m, count(*) as actors return toString(actors) as actorCount, toString(count(m)) as movieCount order by actorCount

Some notes on this:

  • you need to have %neo4 on the beginning to indicate we’re using the previously configured neo4j interpreter
  • for a reason I need to investigate, Zeppelin does not display numeric values returned from Neo4j. Therefore you have to convert numeric results using toString function

See the result:

Zeppelin note with a Cypher query

Zeppelin does not a feature to display nodes and relationships, so a graph view would be nice. If I find some time I wanted to investigate on this – maybe we can come up with a even more rich integration.

Find the perfect platform for a scalable self-service model to manage Big Data workloads in the Cloud. Download the free O'Reilly eBook to learn more.

zeppelin ,big data ,neo4j

Published at DZone with permission of Stefan Armbruster, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}