Skip to content

Instantly share code, notes, and snippets.

@rvanbruggen
Created August 9, 2013 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvanbruggen/6191508 to your computer and use it in GitHub Desktop.
Save rvanbruggen/6191508 to your computer and use it in GitHub Desktop.
Example queries to interactively query a linkedin-based neo4j database.
// Find Shortest paths between two contacts
START
n=node:node_auto_index(name='Emil Eifrem'),
m=node:node_auto_index(name='Steven Noels')
MATCH
p = AllShortestPaths(n-[*]-m)
RETURN p;
// Find all the relationships between two "first degree" contacts of RVB
START
rik=node:node_auto_index(name="Rik Van Bruggen")
MATCH
rik-[:CONNECTED_TO]-firstdegree-[r:CONNECTED_TO]-otherfirstdegree-[:CONNECTED_TO]-rik
RETURN distinct firstdegree.name, r, otherfirstdegree.name;
// Find all the shared contacts between Rik and Lars
START
rik=node:node_auto_index(name="Rik Van Bruggen"),
lars=node:node_auto_index(name="Lars Nordwall")
MATCH
rik-[:CONNECTED_TO]-rixsharedcontacts-[:CONNECTED_TO]-lars
RETURN distinct rixsharedcontacts.name as SharedContacts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment