Skip to content

Instantly share code, notes, and snippets.

@jexp
Created August 22, 2012 21:19
Show Gist options
  • Select an option

  • Save jexp/3429482 to your computer and use it in GitHub Desktop.

Select an option

Save jexp/3429482 to your computer and use it in GitHub Desktop.
Pre-Canned queries for the NoSQL NOW dataset

Index lookup:

start abk=node:speakers(name="Andreas Kollegger") 
return abk;

return properties & id:

start abk=node:speakers(name="Andreas Kollegger") 
return abk.name, id(abk);

follow relationships:

start abk=node:speakers(name="Andreas Kollegger") 
match abk-[:presents]->talk 
return talk.title;

start abk=node:speakers(name="Andreas Kollegger") 
match abk-[:presents]->talk-[:at]->slot 
return talk.title,slot.slot;

which other talks are during those slots:

start abk=node:speakers(name="Andreas Kollegger") 
match abk-[:presents]->talk-[:at]->slot<-[:at]-other 
return talk.title,slot.slot, other.title;

group them into a collection, and count them

start abk=node:speakers(name="Andreas Kollegger") 
match abk-[:presents]->talk-[:at]->slot<-[:at]-other 
return talk.title,slot.slot, collect(other.title) as others, count(*) as cnt;

only see those where there is more than one competing slot

start abk=node:speakers(name="Andreas Kollegger") 
match abk-[:presents]->talk-[:at]->slot<-[:at]-other 
with talk, count(*) as cnt 
where cnt>1 
return talk.title,cnt;

slots are connected with a next relationship, show all slots

start n=node(2) 
match p=n-[:next*0..]->current
return current.slot;

show the talks at the slot

start n=node(2) 
match p=n-[:next*0..]->current<-[:at]-talk 
return current.slot, talk.title;

all talks with the tag Graph Databases

start tag=node:tags(tag="Graph Databases") 
match tag<-[:tagged]-talk
return talk;

which companies talk about graph databases

start tag=node:tags(tag="Graph Databases") 
match tag<-[:tagged]-talk<-[:presents]-speaker-[:works_at]->company 
return talk,speaker,company;

which companies speak about graph databases (with a surprise)

start tag=node:tags(tag="Graph Databases")
match tag<-[:tagged]-talk<-[:presents]-speaker-[:works_at]->company 
return distinct company.company;
require 'rubygems'
require 'neography'
def neo
@neo ||= Neography::Rest.new("http://localhost:7474")
end
def has_rel(node, dir, type)
res = neo.get_node_relationships(node, dir, type)
return res && res.size > 0
end
def add_talk(slot, title, speakers,audience,tags)
root = neo.get_root()
talk = neo.create_node({:title => title})
slot = neo.create_unique_node(:slots, :slot, slot, { :slot => slot})
neo.create_relationship(:at, talk, slot)
speakers.each do |name, from|
speaker = neo.create_unique_node(:speakers, :name, name, { :name => name})
neo.create_relationship(:presents, speaker, talk)
company = neo.create_unique_node(:companies, :company, from, { :company => from})
neo.create_relationship(:works_at, speaker, company) unless has_rel(speaker, :out, :works_at)
end
tags.each do |name|
tag = neo.create_unique_node(:tags, :tag, name, { :tag => name})
neo.create_relationship(:tagged, talk, tag)
neo.create_relationship(:tag, root, tag) unless has_rel(tag,:in, :tag)
end
who = neo.create_unique_node(:audience, :audience, audience, { :audience => audience})
neo.create_relationship(:for, talk, who)
end
neo.execute_query("start n=node(*) match n-[r?]-m where ID(n)<>0 delete n,r")
[:slots, :speakers, :companies, :tags, :audience].each do |name|
neo.create_node_index(name, :exact, :lucene)
end
add_talk("08:30 AM - 09:00 AM",'The Journey to Amazon DynamoDB: From Scaling by Architecture to Scaling by Commandment',
{'Swami Sivasubramanian'=>'Amazon Web Services'}, 'Technical - Introductory', [ 'Cloud Computing',"NoSQL Architecture and Design"])
add_talk("09:00 AM - 09:45 AM", 'Then Our Buildings Shape Us: A new way to think about NoSQL technology selection',
{'Tim Berglund'=>'GitHub'}, 'Business / Non-Technical', [ 'NoSQL Architecture and Design', "NoSQL Technology Evaluation"])
add_talk("09:45 AM - 10:00 AM",'Create Powerful New Applications with Graphs',
{'Emil Eifrem'=>'Neo Technology'}, 'Business / Non-Technical', [ 'Graph Databases'])
add_talk("10:30 AM - 11:15 AM",'Why and When You Should Use Redis',
{'Josiah Carlson'=>'ChowNow Inc.'}, 'Technical - Introductory', [ 'NoSQL Technology Evaluation'])
...
add_talk("10:30 AM - 11:15 AM",'Intro to Graph Databases 101',
{'Andreas Kollegger'=>'Neo Technology'}, 'Technical - Introductory', [ 'Graph Databases'])
...
add_talk("01:15 PM - 02:00 PM",'Lunch N Learn with Neo Technology and Neo4j',
{'Andreas Kollegger'=>'Neo Technology'}, 'Technical - Introductory', [ 'Graph Databases'])
add_talk("02:15 PM - 03:00 PM", 'Using Graph Databases to Analyze Relationships, Risks and Business Opportunities - A Case Study',
{'Jans Aasman'=>'Franz Inc'}, 'Technical - Introductory', [ 'Graph Databases'])
add_talk("04:15 PM - 04:45 PM", 'High performance graph database using cache, cloud, and standards',
{'Bryan Thompson'=>'SYSTAP, LLC'}, 'Technical - Advanced', [ 'Graph Databases'])
....
add_talk("04:15 PM - 04:45 PM", 'Introducing Hadoop and Big Data into a Healthcare Organization: A True Story and Learned Lessons',
{'Vladimir Bacvanski'=>'SciSpike'}, 'Technical - Intermediate', [ 'Big Data'])
add_talk("04:15 PM - 04:45 PM", 'NoSQL Data Modelling for Scalable eCommerce',
{'Dipali Trivedi'=>'Staples.com'}, 'Technical - Intermediate', [ 'NoSQL Architecture and Design'])
add_talk("05:30 PM - 06:30 PM",'The NoSQL "C Panel"', {"Robert Scoble"=>"RackSpace",
"Bob Wiederhold"=>"Couchbase",
"Dwight Merriman"=>"10gen",
"Emil Eifrem"=>"Neo Technology",
"Jay Jarrell"=>"Objectivity, Inc.",
"Kirk Dunn"=>"Cloudera, Inc."},
"Business / Non-Technical",
["Graph Databases", "Hadoop", "MongoDB"])
require 'rubygems'
require 'neography'
def neo
@neo ||= Neography::Rest.new("http://localhost:7474")
end
def has_rel(node, dir, type)
res = neo.get_node_relationships(node, dir, type)
return res && res.size > 0
end
def add_talk(slot, title, speakers,audience,tags)
root = neo.get_root()
talk = neo.create_node({:title => title})
slot = neo.create_unique_node(:slots, :slot, slot, { :slot => slot})
neo.create_relationship(:at, talk, slot)
speakers.each do |name, from|
speaker = neo.create_unique_node(:speakers, :name, name, { :name => name})
neo.create_relationship(:presents, speaker, talk)
company = neo.create_unique_node(:companies, :company, from, { :company => from})
neo.create_relationship(:works_at, speaker, company) unless has_rel(speaker, :out, :works_at)
end
tags.each do |name|
tag = neo.create_unique_node(:tags, :tag, name, { :tag => name})
neo.create_relationship(:tagged, talk, tag)
neo.create_relationship(:tag, root, tag) unless has_rel(tag,:in, :tag)
end
who = neo.create_unique_node(:audience, :audience, audience, { :audience => audience})
neo.create_relationship(:for, talk, who)
end
neo.execute_query("start n=node(*) match n-[r?]-m where ID(n)<>0 delete n,r")
[:slots, :speakers, :companies, :tags, :audience].each do |name|
neo.create_node_index(name, :exact, :lucene)
end
add_talk("08:30 AM - 09:00 AM",'The Journey to Amazon DynamoDB: From Scaling by Architecture to Scaling by Commandment',
{'Swami Sivasubramanian'=>'Amazon Web Services'}, 'Technical - Introductory', [ 'Cloud Computing',"NoSQL Architecture and Design"])
add_talk("09:00 AM - 09:45 AM", 'Then Our Buildings Shape Us: A new way to think about NoSQL technology selection',
{'Tim Berglund'=>'GitHub'}, 'Business / Non-Technical', [ 'NoSQL Architecture and Design', "NoSQL Technology Evaluation"])
add_talk("09:45 AM - 10:00 AM",'Create Powerful New Applications with Graphs',
{'Emil Eifrem'=>'Neo Technology'}, 'Business / Non-Technical', [ 'Graph Databases'])
add_talk("10:30 AM - 11:15 AM",'Why and When You Should Use Redis',
{'Josiah Carlson'=>'ChowNow Inc.'}, 'Technical - Introductory', [ 'NoSQL Technology Evaluation'])
add_talk("10:30 AM - 11:15 AM",'Intro to Graph Databases 101',
{'Andreas Kollegger'=>'Neo Technology'}, 'Technical - Introductory', [ 'Graph Databases'])
add_talk("10:30 AM - 11:15 AM", 'OldSQL, NoSQL, and NewSQL, Huh?',
{'Mike Bowers'=>'LDS'}, 'Technical - Intermediate', [ 'NoSQL for the Enterprise',"NoSQL Technology Evaluation"])
add_talk("10:30 AM - 11:15 AM", 'Real time analytics for Big Data - a Twitter case study',
{'Nati Shalom'=>'GigaSpaces'}, 'Technical - Intermediate', [ 'Big Data',"Business Intelligence and Analytics"])
add_talk("10:30 AM - 11:15 AM", 'Common MongoDB Use Cases',
{'Dwight Merriman'=>'10gen'}, 'Technical - Introductory', [ 'NoSQL for the Enterprise',"MongoDB"])
add_talk("11:30 AM - 12:15 PM", 'Dropping ACID: Architecting with Eventual Consistency in the Cloud',
{'Jason Bloomberg'=>'ZapThink, A Dovel Technologies Company'}, 'Technical - Introductory', [ 'NoSQL Architecture and Design', "Cloud Computing"])
add_talk("11:30 AM - 12:15 PM", 'Think Outside the Grid. Non-Square Data Management.',
{'Robert Charles Greene'=>'Versant Corporation'}, 'Technical - Advanced', [ 'Hadoop'])
add_talk("11:30 AM - 12:15 PM", 'Transform Big Data into Actionable Intelligence with Graphs',
{'Leon Guzenda'=>'Objectivity'}, 'Business / Non-Technical', [ 'Graph Databases',"Big Data"])
add_talk("11:30 AM - 12:15 PM", 'Case Study: How to Reach Customers Faster and Make More Money with a NoSQL Database',
{'Niklas Björkman'=>'Adtoma AB'}, 'Technical - Intermediate', [ 'NoSQL Architecture and Design'])
add_talk("11:30 AM - 12:15 PM", 'In the trenches with a NoSQL database – lessons learned from a fast growing startup ',
{'Troy Howard'=>'AppFog'}, 'Technical - Intermediate', [ 'Cloud Computing'])
add_talk("12:30 PM - 01:00 PM", 'Big Data, Fast Data, and Complex Data - Defining and Overcoming Challenges',
{'Jans Aasman'=>'Franz Inc'}, 'Technical - Introductory', [ 'Big Data',"Graph Databases"])
add_talk("12:30 PM - 01:00 PM", 'Go Simple, Fast, Elastic with Couchbase Server and Document-oriented Data Management',
{'Dipti Borkar'=>'Couchbase'}, 'Technical - Intermediate', [ 'NoSQL Technology Evaluation'])
add_talk("12:30 PM - 01:00 PM", 'Introduction to InfiniteGraph – The Distributed Enterprise Graph Database',
{'Darren Wood'=>'Objectivity'}, 'Technical - Introductory', [ 'Graph Databases'])
add_talk("12:30 PM - 01:00 PM", 'Analytica: Analytics for MongoDB and NoSQL Databases',
{'Christoph Bussler'=>'Analytica, Inc.'}, 'Business / Non-Technical', [ 'Business Intelligence and Analytics'])
add_talk("12:30 PM - 01:00 PM", 'Moving Beyond the No/New/SQL Debate: Introducing the Application Data Layer',
{'Mike Miller'=>'Cloudant'}, 'Technical - Intermediate', [ 'NoSQL Architecture and Design'])
add_talk("01:15 PM - 02:00 PM",'Lunch N Learn with Neo Technology and Neo4j',
{'Andreas Kollegger'=>'Neo Technology'}, 'Technical - Introductory', [ 'Graph Databases'])
add_talk("01:15 PM - 02:00 PM", 'VoltDB - High Velocity Data Management',
{'Ryan Betts'=>'VoltDB, Inc.'}, 'Technical - Intermediate', [ 'NewSQL'])
add_talk("02:15 PM - 03:00 PM", 'Performance Benchmarks for Cassandra on AWS',
{'Adrian Cockcroft'=>'Netflix'}, 'Technical - Advanced', [ 'Cloud Computing'])
add_talk("02:15 PM - 03:00 PM", 'SQL and NoSQL – Bridging the gap',
{'David Rubin'=>'Oracle Corp.'}, 'Business / Non-Technical', [ 'NoSQL for the Enterprise'])
add_talk( "02:15 PM - 03:00 PM",'NoSQL Kool-Aid - Shaken Not Stirred; Real Reasons for using NoSQL or RDBMS',
{'Raghu Bala'=>'Source Interlink Media'}, 'Technical - Introductory', [ 'NoSQL Architecture and Design'])
add_talk("02:15 PM - 03:00 PM", 'Using Graph Databases to Analyze Relationships, Risks and Business Opportunities - A Case Study',
{'Jans Aasman'=>'Franz Inc'}, 'Technical - Introductory', [ 'Graph Databases'])
add_talk("02:15 PM - 03:00 PM", 'Mobilize Your MongoDB! Developing iPhone and Android Apps in the Cloud',
{'Grant Shipley'=>'Red Hat'}, 'Technical - Intermediate', [ 'Cloud Computing'])
add_talk("03:15 PM - 04:00 PM", 'Keeping up with Streaming/Sensor Data',
{'David R Brown'=>'EMC'}, 'Technical - Introductory', [ 'Business Intelligence and Analytics'])
add_talk("03:15 PM - 04:00 PM", 'Evolving Neo4J for the Cloud',
{'Stephen Cole'=>'Adobe Systems, Inc.'}, 'Business / Non-Technical', [ 'Graph Databases'])
add_talk("03:15 PM - 04:00 PM", 'Apache Cassandra: NoSQL applications in the enterprise today',
{'Jonathan Ellis'=>'DataStax'}, 'Technical - Introductory', [ 'NoSQL for the Enterprise'])
add_talk("03:15 PM - 04:00 PM", 'NoSQL in the Cloud with Windows Azure Table',
{'Jai Haridas'=>'Microsoft Corporation'}, 'Technical - Intermediate', [ 'Cloud Computing'])
add_talk("03:15 PM - 04:00 PM", 'Building Mobile Applications with NoSQL',
{'J. Chris Anderson'=>'Couchbase'}, 'Technical - Introductory', [ 'NoSQL Architecture and Design'])
add_talk("04:15 PM - 04:45 PM", 'Case Study: Making Hadoop & Cassandra Work Together to process 5+Tb of Data Daily',
{'Renat Khasanshyn'=>'Altoros Systems, Inc.'}, 'Technical - Introductory', [ 'Cassandra'])
add_talk("04:15 PM - 04:45 PM", 'High performance graph database using cache, cloud, and standards',
{'Bryan Thompson'=>'SYSTAP, LLC'}, 'Technical - Advanced', [ 'Graph Databases'])
add_talk("04:15 PM - 04:45 PM", 'Advantages of using MongoDB in a Single Page Web Application',
{'Josh Powell'=>'Rocket Fuel'}, 'Technical - Intermediate', [ 'MongoDB'])
add_talk("04:15 PM - 04:45 PM", 'Introducing Hadoop and Big Data into a Healthcare Organization: A True Story and Learned Lessons',
{'Vladimir Bacvanski'=>'SciSpike'}, 'Technical - Intermediate', [ 'Big Data'])
add_talk("04:15 PM - 04:45 PM", 'NoSQL Data Modelling for Scalable eCommerce',
{'Dipali Trivedi'=>'Staples.com'}, 'Technical - Intermediate', [ 'NoSQL Architecture and Design'])
add_talk("05:30 PM - 06:30 PM",'The NoSQL "C Panel"', {"Robert Scoble"=>"RackSpace",
"Bob Wiederhold"=>"Couchbase",
"Dwight Merriman"=>"10gen",
"Emil Eifrem"=>"Neo Technology",
"Jay Jarrell"=>"Objectivity, Inc.",
"Kirk Dunn"=>"Cloudera, Inc."},
"Business / Non-Technical",
["Graph Databases", "Hadoop", "MongoDB"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment