This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
ruby "2.1.1" | |
gem 'sinatra', '1.1.0' | |
gem 'neo4j-core', '3.0.0.alpha.11' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
require 'forwardable' | |
require 'fileutils' | |
# Load Neo4j Jars for the jars folder | |
# Put the neo4j 2.0 jars there | |
jar_folder = File.expand_path('../jars', __FILE__) | |
jars = Dir.new(jar_folder).entries.find_all { |x| x =~ /\.jar$/ } | |
jars.each { |jar| require File.expand_path(jar, jar_folder) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'neo4j' | |
class Show < Neo4j::Rails::Model | |
property :show_name, type: String, index: :exact | |
has_n :booked_bands | |
end | |
#I have another model, band.rb | |
class Band < Neo4j::Rails::Model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TransactionalExec | |
attr_accessor :commit_every, :block | |
def initialize(commit_every, max_lines = nil, verbose = true, &block) | |
@commit_every = commit_every | |
@block = block | |
@max_lines = max_lines | |
@verbose = verbose | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rails', '3.2.9' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'jruby-openssl' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
me = lookup('node_auto_index', 'name', "Joe").as(:me) | |
me > rel(:favorite) > node(:myFavorites) > rel(:tagged) > node(:tag) < rel(:tagged) < node(:theirFavorites) < rel(:favorite) < node(:people) | |
me != node(:people) | |
ret node(:people)[:name].as(:name), count.desc.as(:similar_favs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Environment | |
=========== | |
Mac OSX | |
jruby 1.7.0.preview2 | |
java version "1.7.0_05" | |
Java(TM) SE Runtime Environment (build 1.7.0_05-b05) | |
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode) | |
How to Reproduce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'neo4j-core' | |
def connect(d) | |
d.each{|i| Neo4j::Relationship.new(:flies_to, i[:from], i[:to])} | |
end | |
tx = Neo4j::Transaction.new | |
@a, @b, @c, @z = %w[A B C D].map{|name| Neo4j::Node.new(:name => name)} | |
connect([ {:from=>@a, :to=>@b}, {:from=>@a, :to=>@c}, {:from=>@b, :to=>@c}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load 'nodes.rb' | |
require 'rubygems' | |
require 'neo4j' | |
alice = Neo4j::Transaction.run { Neo4j::Node.new } | |
bob = Neo4j::Transaction.run { Neo4j::Node.new } | |
Neo4j::Transaction.run do | |
alice[:name] = "alice" | |
alice[:score] = [42,4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recommend = Neo4j.query do | |
node(alice).where_not{|me| me > ':follows' > :user} > ':used_tag' > :tag < ':used_tag' < :user | |
ret(node(:user), count(:tag).desc(count(:tag))) | |
end.first[:user] |