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
# This SPIKE is now commited in branch rest: http://github.com/andreasronge/neo4j/tree/restful | |
# This is a old, see branch for new code, example and a spike of how RESTful Neo4j API would work | |
require 'rubygems' | |
require 'json' | |
require 'sinatra/base' | |
require 'neo4j' | |
# This mixin creates the following restful resources |
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 'model' # from the example/imdb neo4j.rb example | |
class Actor | |
def acted_in_cool_movies | |
traverse.outgoing(:acted_in).find_all {|movie| movie.relationship?(:cool_movies, :incoming)} | |
end | |
end | |
cool_movies = Node.new | |
all_cool_movies = [m1,m2] # m1,m2 are two movies - defined somewhere else |
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" | |
class Person | |
include Neo4j::NodeMixin | |
# define Neo4j properties | |
property :name | |
# define an one way relationship to any other node |
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' | |
# include the Module so we can skip the Neo4j:: prefix | |
include Neo4j | |
# this node is accessible from Neo4j.ref_node | |
# add a relationship to the top principal = All principals | |
class Neo4j::ReferenceNode | |
has_one :top_principal |
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' | |
include Neo4j | |
Transaction.new | |
# create some people | |
andreas = Node.new :name => 'andreas' | |
peter = Node.new :name => 'peter' | |
kalle = Node.new :name => 'kalle' |
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
module Neo4j | |
module Batch | |
# == Usage | |
# | |
# === Nodes/Properties and Relationships | |
# | |
# Example: | |
# | |
# inserter = Neo4j::Batch::Inserter.new(config, storage) |
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
# | |
# A fatal error has been detected by the Java Runtime Environment: | |
# | |
# SIGSEGV (0xb) at pc=0xb3746cdd, pid=9500, tid=2348546928 | |
# | |
# JRE version: 6.0_24-b07 | |
# Java VM: Java HotSpot(TM) Server VM (19.1-b02 mixed mode linux-x86 ) | |
# Problematic frame: | |
# J org.jruby.RubyBasicObject.getRuntime()Lorg/jruby/Ruby; | |
# |
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
InvokeDynamicSupport.java:2541:in `findVirtual': java.lang.RuntimeException: java.lang.IllegalAccessException: symbolic reference class is not public: class org.neo4j.kernel.impl.core.RelationshipProxy, from org.jruby.runtime.invokedyna$ | |
from InvokeDynamicSupport.java:1603:in `createJavaHandle' | |
from InvokeDynamicSupport.java:1103:in `handleForMethod' | |
from InvokeDynamicSupport.java:1059:in `tryDispatchDirect' | |
from InvokeDynamicSupport.java:1065:in `getTarget' | |
from InvokeDynamicSupport.java:441:in `invocationFallback' | |
from jruby.rb:28:in `method__2$RUBY$visit_ref_node' | |
from jruby$method__2$RUBY$visit_ref_node:65535:in `call' | |
from jruby$method__2$RUBY$visit_ref_node:65535:in `call' | |
from InvokeDynamicSupport.java:1244:in `fail' |
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] |
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] |
OlderNewer