background preloader

Neo4j

Facebook Twitter

Arrow Tool. Neo4j: Cypher – Creating a time tree down to the day at Mark Needham. Michael recently wrote a blog post showing how to create a time tree representing time down to the second using Neo4j’s Cypher query language, something I built on top of for a side project I’m working on.

Neo4j: Cypher – Creating a time tree down to the day at Mark Needham

The domain I want to model is RSVPs to meetup invites – I want to understand how much in advance people respond and how likely they are to drop out at a later stage. For this problem I only need to measure time down to the day so my task is a bit easier than Michael’s. After a bit of fiddling around with leap years I believe the following query will create a time tree representing all the days from 2011 – 2014, which covers the time the London Neo4j meetup has been running: The next step is to link adjacent days together so that we can easily traverse between adjacent days without needing to go back up and down the tree.

For example we should have something like this: We can build this by first collecting all the ‘day’ nodes in date order like so: Alexander Smirnov's personal Weblog. Recently, I needed to add ‘graph relations’ to the data objects in the some JEE application.

Alexander Smirnov's personal Weblog

That application uses JPA and MySQL to store data objects, and first attempt was done by adding “many-to-many” relationships that points back to entity itself, but such schema doesnt work well in SQL. Therefore, we decided to keep graph-like relationships in the Neo4j database. The next question was: how to add Neo4j to our application and how to coordinate transactions between JPA and Neo4j ? Because we run inside Glassfish 3.1 container, we put graph database outside of application and created Java EE connector neo4j-connector that deployed to server as resource adaptor and manages Neo4j database.

Application get instance of GraphDatabaseService from JNDI and doesn’t have to care about database startup/shutdown, configuration, and transactions. Connector features: Standard JCA 1.6 connector, that can be installed on any Java EE 6 compatible server. Usage. Future plans. Hibernate OGM Reference Guide. If you are familiar with JPA, you are almost good to go :-) We will nevertheless walk you through the first few steps of persisting and retrieving an entity using Hibernate OGM.

Hibernate OGM Reference Guide

Before we can start, make sure you have the following tools configured: Java JDK 6 or above Maven 3.x Hibernate OGM is published in the JBoss hosted Maven repository. Adjust your ~/.m2/settings.xml file according to the guidelines found on this webpage. JPA Tutorial for Neo4j. DataNucleus - Tutorial for JPA for Neo4j Background An application can be JPA-enabled via many routes depending on the development process of the project in question.

JPA Tutorial for Neo4j

For example the project could use Eclipse as the IDE for developing classes. In that case the project would typically use the Dali Eclipse plugin coupled with the DataNucleus Eclipse plugin. Alternatively the project could use Ant, Maven2 or some other build tool. Prerequisite : Download DataNucleus AccessPlatform Step 1 : Define their persistence definition using Meta-Data. The tutorial guides you through this. Working with a Neo4j Embedded Database. (For more resources related to this topic, see here.)

Working with a Neo4j Embedded Database

Neo4j is a graph database, which means that it does not use tables and rows to represent data logically; instead, it uses nodes and relationships. Both nodes and relationships can have a number of properties. While relationships must have one direction and one type, nodes can have a number of labels. For example, the following diagram shows three nodes and their relationships, where every node has a label (language or graph database), while relationships have a type (QUERY_LANGUAGE_OF and WRITTEN_IN). The properties used in the graph shown in the following diagram are: name, type, and from. Batch Importer – Part 1. Data is everywhere… all around us, but sometimes the medium it is stored in can be a problem when analyzing it.

Batch Importer – Part 1

Chances are you have a ton of data sitting around in a relational database in your current application… or you have begged, borrowed or scraped to get the data from somewhere and now you want to use Neo4j to find how this data is related. Michael Hunger wrote a batch importer to load csv data quickly, but for some reason it hasn’t received a lot of love. We’re going to change that today and I’m going to walk you through getting your data out of tables and into nodes and edges. Let’s clone the project and jump in. It uses Maven, so if you haven’t already go ahead and install it.

Now let’s assemble the project per the instructions: If you did it right, you should see: Awesome… let’s create some test data. It will take a little while, and then you should see this: Really where? So what’s in nodes.csv? The format is property_1, property_2, property_3 separated by tabs… and rels.csv: 5.1. Server Installation. Neo4j can be installed as a server, running either as a headless application or system service.

5.1. Server Installation

Download the latest release from select the appropriate version for your platform Extract the contents of the archive refer to the top-level extracted directory as NEO4J-HOME Use the scripts in the bin directory for Linux/MacOS, run $NEO4J_HOME/bin/neo4j start for Windows, double-click on %NEO4J_HOME%\bin\Neo4j.bat Refer to the packaged information in the doc directory for details 5.1.1. As a Windows service With administrative rights, Neo4j can be installed as a Windows service. Click Start → All Programs → Accessories Right click Command Prompt → Run as Administrator Provide authorization and/or the Administrator password Navigate to %NEO4J_HOME% Run bin\Neo4j.bat install. Open Source Integration Software and Data Management Tools. Preface - - The Neo4j Manual v2.1.5. This is the reference manual for Neo4j version 2.1.5, authored by the Neo4j Team.

Preface - - The Neo4j Manual v2.1.5

The main parts of the manual are: The material is practical, technical, and focused on answering specific questions. On Importing Data into Neo4j (Blog Series) Posted by Michael Hunger on May 25, 2013 in development, neo4j | Being able to run interesting queries against a graph database like Neo4j requires the data to be in there in the first place.

On Importing Data into Neo4j (Blog Series)

As many users have questions in this area, I thought a series on importing data into Neo4j would be helpful to get started. This series covers both importing small and moderate data volumes for examples and demonstrations, but also large scale data ingestion. For operations where massive amounts of data flow in or out of a Neo4j database, the interaction with the available APIs should be more considerate than with your usual, ad-hoc, local graph queries. This blog series will discuss several ways of importing data into Neo4j and the considerations you should make when choosing one or the other.