Category Archives: Cypher

Mutual Fund Benchmarks with Neo4j

Just the other day I had a conversation with an Investment Risk Manager about one of the data problems his team was working on and he was wondering if Neo4j could help. Imagine you have about 20,000 mutual funds and etfs and you want to track how they measure up against a benchmark like say the returns of the S&P 500. I’m sorry did I say one? I meant all of them, let’s say 2,000 different benchmarks… and you want to track it every day, for a rolling 5 years period. So that’s 20,000 securities * 2000 benchmarks * 5 years * 252 trading days a year (on average)… or 50 billion data points. That’s a BIG join table if we were using a relational database. How can we efficiently model this in Neo4j?
Continue reading

Tagged , , , , , , , ,

Bill of Materials in Neo4j

Where is da BOM? The above question asks, and the obvious answer is right in the middle of your organization. Nestled between Manufacturing, Design, Sales and Supply Chain. But I have a better answer. Your Bill of Materials should be in Neo4j. Today, I’ll show you why.
Continue reading

Tagged , , , , , , , , , ,

Counting Nodes with Multiple Labels

We have over 6000 users in our #neo4j-users slack channel and get all kinds of requests. About a month ago Thomas Shields asked:

Should counting the set of things with 2 labels really take so long? I’ve got 48M nodes with LabelA and LabelB and the query `MATCH (n:LabelA:LabelB) RETURN COUNT(n)` is taking 80-90 seconds

Let’s see what’s going on by creating a small version of his graph. We will create 1M nodes of LabelA, then 1M nodes with both LabelA and LabelB, and then 1M nodes with just Label B:
Continue reading

Tagged , , , , , ,

Finding Triplets with Neo4j

A user had an interesting Neo4j question on Stack Overflow the other day:

I have two types of nodes in my graph. One type is Testplan and the other is Tag. Testplans are tagged to Tags. I want most common pairs of Tags that share the same Testplans with a Tag having a specific name. I have been able to achieve the most common Tags sharing the same Testplan with one Tag, but getting confused when trying to do it for pairs of Tags.

Continue reading

Tagged , , , , , , , ,

Building a Twitter Clone with Neo4j – Part One

Would you believe there is no shortage of Twitter Clone example applications…maybe because they are easy to replicate (ba dum tss, I’ll be here all week.) The earliest one I remember was written by Salvatore Sanfilippo creator of Redis.
It’s a pretty good read, where he explains the basics of Redis (a Key Value store on steroids) and how to model a social network in it. One of the interesting bits to me is how the status updates (tweets) are handled.
Continue reading

Tagged , , , , , , , , ,

Neo4j is faster than MySQL in performing recursive query

5mysql

A user on StackOverflow was wondering about the performance between Neo4j and MySQL for performing a recursive query. They started with Neo4j performing the query in 240 seconds. Then an optimized cypher query got them down to 40 seconds. Then I got them down to…
Continue reading

Tagged , , , , , , , , , , ,

Writing a Cypher Stored Procedure

luke-cage-jidenna

I’ve been so busy these last 6 months I just finally got around to watching Luke Cage on Netflix. The season 1 episode 5 intro is Jidenna performing “Long live the Chief” and it made me pause the series while I figured out who that was. I’m mostly a hard rock and heavy metal guy, but I do appreciate great pieces of lyrical work and this song made me take notice. Coincidently on the Neo4j Users Slack (get an invite) @sleo asked…
Continue reading

Tagged , , , , , , , , , ,

Property Level Security with Neo4j Enterprise

security-patrol-guard

In Neo4j 3.1 Enterprise edition, we introduced the first wave of security features that are coming down the pipeline. Now you can start off with Administrators, Architects, Publishers and Readers as built in default groups. You can read about their capabilities in the docs.

If you’ve been paying attention, you know Neo4j thrives under it’s dynamic customizability. The developers decided to let us build our own custom Roles and limit their capabilities to a set of Stored Procedures. With this, we can build any kind of access control we want, but let’s go for the jugular and let’s see how we can build property level security for Neo4j.
Continue reading

Tagged , , , , , ,

Enabling Legacy Automatic Full Text Search on Neo4j 3.x

solar-elastic-lucene

Neo4j 3.x has made inroads toward Full Text Search capabilities using Cypher keywords “STARTS WITH”, “ENDS WITH” and “CONTAINS”. However this search capability is limited to a single Schema Index and can be a problem when you need a very flexible search interface. To search across multiple models you can do this trick:
Continue reading

Tagged , , , , ,

News Feeds

Ron Burgundy Gets Hungry

Ron Burgundy (in Anchorman) gets Hungry

The “News Feed” is a core feature of social networks like Twitter, Facebook, or Vine (RIP). Let’s take a look at how we could model and implement this in Neo4j. Our social network needs Users (otherwise it would be kinda empty) that FOLLOW each other (otherwise it would not be very social). Those users need to POST some Messages (otherwise it would be boring). Here is our first attempt at a model (using Arrows):
Continue reading

Tagged , , , , , , ,