Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 397 lines (297 sloc) 24.548 kb
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
1 == Welcome to Neography
2
90cb6ed @maxdemarzi adding traverser
maxdemarzi authored
3 Neography is a thin Ruby wrapper to the Neo4j Rest API, for more information:
72c11fc @dchelimsky update link to community server
dchelimsky authored
4 * {Getting Started with Neo4j Server}[http://neo4j.org/community/]
839b2fb @dchelimsky update link to rest api
dchelimsky authored
5 * {Neo4j Rest API Reference}[http://docs.neo4j.org/chunked/milestone/rest-api.html]
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
6
764a146 @maxdemarzi adding tasks
maxdemarzi authored
7 If you want to the full power of Neo4j, you will want to use JRuby and the excellent Neo4j.rb gem at https://github.com/andreasronge/neo4j by Andreas Ronge
8
3313e4a @maxdemarzi adding tests and readme for unique nodes and relationships
maxdemarzi authored
9 Complement to Neography are the:
1f217fb @maxdemarzi Update README.rdoc
maxdemarzi authored
10
11 * {Neo4j Active Record Adapter}[https://github.com/yournextleap/activerecord-neo4j-adapter] by Nikhil Lanjewar
12 * {Neology}[https://github.com/lordkada/neology] by Carlo Alberto Degli Atti
13 * {Neoid}[https://github.com/elado/neoid] by Elad Ossadon
764a146 @maxdemarzi adding tasks
maxdemarzi authored
14
15 An alternative is the Architect4r Gem at https://github.com/namxam/architect4r by Maximilian Schulz
16
aec2a73 @maxdemarzi adding some sample links to readme
maxdemarzi authored
17 === Neography in the Wild
18
569d791 @maxdemarzi make links pretty
maxdemarzi authored
19 * {Vouched}[http://getvouched.com]
47c2539 @maxdemarzi lets try that again
maxdemarzi authored
20 * {Neovigator}[http://neovigator.herokuapp.com] fork it at https://github.com/maxdemarzi/neovigator
21 * {Neoflix}[http://neoflix.herokuapp.com] fork it at https://github.com/maxdemarzi/neoflix
aec2a73 @maxdemarzi adding some sample links to readme
maxdemarzi authored
22
23 === Getting started with Neography
24
47c2539 @maxdemarzi lets try that again
maxdemarzi authored
25 * {Getting Started with Ruby and Neo4j}[http://maxdemarzi.com/2012/01/04/getting-started-with-ruby-and-neo4j/]
26 * {Graph visualization with Neo4j}[http://maxdemarzi.com/2012/01/11/graph-visualization-and-neo4j/]
27 * {Neo4j on Heroku}[http://maxdemarzi.com/2012/01/13/neo4j-on-heroku-part-one/]
aec2a73 @maxdemarzi adding some sample links to readme
maxdemarzi authored
28
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
29
30 === Installation
31
633206b @maxdemarzi removed reference to Neo4j 1.4 and neography 0.14 since it's really old
maxdemarzi authored
32 gem install 'neography'
1097667 @maxdemarzi Use version 0.0.l4 for Neo4j 1.4 and 0.0.15 for Neo4j 1.5
maxdemarzi authored
33
cafaf2e @peterneubauer
peterneubauer authored
34
6b29ca8 @maxdemarzi try neography at neography.org
maxdemarzi authored
35 After that, in your ruby script:
cafaf2e @peterneubauer
peterneubauer authored
36
37 require 'rubygems'
3a1cef5 @maxdemarzi make readme prettier
maxdemarzi authored
38 require 'neography'
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
39
cafaf2e @peterneubauer
peterneubauer authored
40 in order to access the functionality.
6b29ca8 @maxdemarzi try neography at neography.org
maxdemarzi authored
41
42
e42beda @maxdemarzi more cleanup
maxdemarzi authored
43 === Dependencies
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
44
e42beda @maxdemarzi more cleanup
maxdemarzi authored
45 for use:
c88b20a @maxdemarzi adding parameters to cypher calls
maxdemarzi authored
46 os
47 rake
e42beda @maxdemarzi more cleanup
maxdemarzi authored
48 json
49 httparty
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
50
e42beda @maxdemarzi more cleanup
maxdemarzi authored
51 for development:
52 rspec
53 net-http-spy
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
54
55 ==== Rails
56
752924a @maxdemarzi added railtie to autoload tasks
maxdemarzi authored
57 Just add gem 'neography' to your Gemfile and run bundle install.
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
58
752924a @maxdemarzi added railtie to autoload tasks
maxdemarzi authored
59 The following tasks will be available to you:
764a146 @maxdemarzi adding tasks
maxdemarzi authored
60
7c204f0 @maxdemarzi pick your own version
maxdemarzi authored
61 rake neo4j:install # Install Neo4j to the neo4j directory under your project
cddabd3 @maxdemarzi trying Neo4j 1.6M03
maxdemarzi authored
62 rake neo4j:install[community,1.6.M03] # Install Neo4j Community edition, version 1.6.M03
7c204f0 @maxdemarzi pick your own version
maxdemarzi authored
63 rake neo4j:install[advanced,1.5] # Install Neo4j Advanced edition, version 1.5
64 rake neo4j:install[enterprise,1.5] # Install Neo4j Enterprise edition, version 1.5
764a146 @maxdemarzi adding tasks
maxdemarzi authored
65 rake neo4j:start # Start Neo4j
66 rake neo4j:stop # Stop Neo4j
67 rake neo4j:restart # Restart Neo4j
68 rake neo4j:reset_yes_i_am_sure # Wipe your Neo4j Database
69
066ed4f @maxdemarzi ugly attempt at a multi-os installer
maxdemarzi authored
70 Windows users will need to run in a command prompt with Administrative Privileges
71 in order to install Neo4j as a Service.
72
752924a @maxdemarzi added railtie to autoload tasks
maxdemarzi authored
73 If you are not using Rails, then add:
74
75 require 'neography/tasks'
76
77 to your Rakefile to have access to these tasks.
78
79
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
80 === Documentation
81
49fe9ac @maxdemarzi adding authentication options, fixing index tests
maxdemarzi authored
82 @neo = Neography::Rest.new({:protocol => 'http://',
83 :server => 'localhost',
84 :port => 7474,
85 :directory => '', # use '/<my directory>' or leave out for default
86 :authentication => 'basic', # 'basic', 'digest' or leave out for default
87 :username => 'your username', #leave out for default
88 :password => 'your password', #leave out for default
89 :log_file => 'neography.log',
90 :log_enabled => false,
8a73e74 @maxdemarzi adding cypher_path and gremlin_path options
maxdemarzi authored
91 :max_threads => 20,
92 :cypher_path => '/cypher',
93 :gremlin_path => '/ext/GremlinPlugin/graphdb/execute_script'})
e42beda @maxdemarzi more cleanup
maxdemarzi authored
94
ab853ae @maxdemarzi quick initializer
maxdemarzi authored
95 Quick initializer (assumes basic authorization if username is given):
96
97 @neo = Neography::Rest.new("http://username:password@myserver.com:7474/mydirectory")
98
99
e42beda @maxdemarzi more cleanup
maxdemarzi authored
100 To Use:
101
ab853ae @maxdemarzi quick initializer
maxdemarzi authored
102 @neo = Neography::Rest.new # Inialize using all default parameters
e42beda @maxdemarzi more cleanup
maxdemarzi authored
103
c3a00a0 @maxdemarzi added find_id and cleaned up tests
maxdemarzi authored
104 @neo.get_root # Get the root node
3313e4a @maxdemarzi adding tests and readme for unique nodes and relationships
maxdemarzi authored
105 @neo.create_node # Create an empty node
106 @neo.create_node("age" => 31, "name" => "Max") # Create a node with some properties
107 @neo.create_unique_node(index_name, key, unique_value, # Create a unique node
108 {"age" => 31, "name" => "Max"}) # this needs an existing index
109
c3a00a0 @maxdemarzi added find_id and cleaned up tests
maxdemarzi authored
110 @neo.get_node(node2) # Get a node and its properties
111 @neo.delete_node(node2) # Delete an unrelated node
112 @neo.delete_node!(node2) # Delete a node and all its relationships
113
114 @neo.reset_node_properties(node1, {"age" => 31}) # Reset a node's properties
115 @neo.set_node_properties(node1, {"weight" => 200}) # Set a node's properties
116 @neo.get_node_properties(node1) # Get just the node properties
117 @neo.get_node_properties(node1, ["weight","age"]) # Get some of the node properties
118 @neo.remove_node_properties(node1) # Remove all properties of a node
119 @neo.remove_node_properties(node1, "weight") # Remove one property of a node
120 @neo.remove_node_properties(node1, ["weight","age"]) # Remove multiple properties of a node
121
3313e4a @maxdemarzi adding tests and readme for unique nodes and relationships
maxdemarzi authored
122 @neo.create_relationship("friends", node1, node2) # Create a relationship between node1 and node2
123 @neo.create_unique_relationship(index_name, key, value, # Create a unique relationship between nodes
124 "friends", new_node1, new_node2) # this needs an existing index
125
126 @neo.get_relationship(rel1) # Get a relationship
c3a00a0 @maxdemarzi added find_id and cleaned up tests
maxdemarzi authored
127 @neo.get_node_relationships(node1) # Get all relationships
128 @neo.get_node_relationships(node1, "in") # Get only incoming relationships
129 @neo.get_node_relationships(node1, "all", "enemies") # Get all relationships of type enemies
130 @neo.get_node_relationships(node1, "in", "enemies") # Get only incoming relationships of type enemies
131 @neo.delete_relationship(rel1) # Delete a relationship
132
133 @neo.reset_relationship_properties(rel1, {"age" => 31}) # Reset a relationship's properties
134 @neo.set_relationship_properties(rel1, {"weight" => 200}) # Set a relationship's properties
135 @neo.get_relationship_properties(rel1) # Get just the relationship properties
136 @neo.get_relationship_properties(rel1, ["since","met"]) # Get some of the relationship properties
137 @neo.remove_relationship_properties(rel1) # Remove all properties of a relationship
138 @neo.remove_relationship_properties(rel1, "since") # Remove one property of a relationship
139 @neo.remove_relationship_properties(rel1, ["since","met"]) # Remove multiple properties of a relationship
140
2015a05 @maxdemarzi working on relationship indexes
maxdemarzi authored
141 @neo.list_node_indexes # gives names and query templates for all defined indices
b32f7e1 @maxdemarzi adding create node and relationship index
maxdemarzi authored
142 @neo.create_node_index(name, type, provider) # creates an index, defaults are "exact" and "lucene"
2015a05 @maxdemarzi working on relationship indexes
maxdemarzi authored
143 @neo.add_node_to_index(index, key, value, node1) # adds a node to the index with the given key/value pair
144 @neo.remove_node_from_index(index, key, value, node1) # removes a node from the index with the given key/value pair
3e41e09 @maxdemarzi adding new ways to remove nodes and relationships from an index
maxdemarzi authored
145 @neo.remove_node_from_index(index, key, node1) # removes a node from the index with the given key
146 @neo.remove_node_from_index(index, node1) # removes a node from the index
10c8228 @maxdemarzi advanced queries of the node and relationship indexes
maxdemarzi authored
147 @neo.get_node_index(index, key, value) # exact query of the node index with the given key/value pair
148 @neo.find_node_index(index, key, value) # advanced query of the node index with the given key/value pair
bc49b90 @lordkada finding nodes and relationships through query. Remote Groovy script thro...
lordkada authored
149 @neo.find_node_index(index, query ) # advanced query of the node index with the given query
2015a05 @maxdemarzi working on relationship indexes
maxdemarzi authored
150 @neo.list_relationship_indexes # gives names and query templates for relationship indices
9118a80 @maxdemarzi typo in relationship readme
maxdemarzi authored
151 @neo.create_relationship_index(name, "fulltext", provider) # creates a relationship index with "fulltext" option
2015a05 @maxdemarzi working on relationship indexes
maxdemarzi authored
152 @neo.add_relationship_to_index(index, key, value, rel1) # adds a relationship to the index with the given key/value pair
153 @neo.remove_relationship_from_index(index, key, value, rel1) # removes a relationship from the index with the given key/value pair
3e41e09 @maxdemarzi adding new ways to remove nodes and relationships from an index
maxdemarzi authored
154 @neo.remove_relationship_from_index(index, key, rel1) # removes a relationship from the index with the given key
155 @neo.remove_relationship_from_index(index, rel1) # removes a relationship from the index
10c8228 @maxdemarzi advanced queries of the node and relationship indexes
maxdemarzi authored
156 @neo.get_relationship_index(index, key, value) # exact query of the relationship index with the given key/value pair
157 @neo.find_relationship_index(index, key, value) # advanced query of the relationship index with the given key/value pair
bc49b90 @lordkada finding nodes and relationships through query. Remote Groovy script thro...
lordkada authored
158 @neo.find_relationship_index(index, query) # advanced query of the relationship index with the given query
c88b20a @maxdemarzi adding parameters to cypher calls
maxdemarzi authored
159 @neo.execute_script("g.v(0)") # sends a Groovy script (through the Gremlin plugin)
160 @neo.execute_script("g.v(id)", {:id => 3}) # sends a parameterized Groovy script (optimized for repeated calls)
7a5c6a8 @maxdemarzi removing fakeweb, escaping execute_script for gremlin, adding execute_qu...
maxdemarzi authored
161 @neo.execute_query("start n=node(0) return n") # sends a Cypher query (through the Cypher plugin)
c88b20a @maxdemarzi adding parameters to cypher calls
maxdemarzi authored
162 @neo.execute_query("start n=node(id) return n", {:id => 3}) # sends a parameterized Cypher query (optimized for repeated calls)
c3a00a0 @maxdemarzi added find_id and cleaned up tests
maxdemarzi authored
163
164 @neo.get_path(node1, node2, relationships, depth=4, algorithm="shortestPath") # finds the shortest path between two nodes
165 @neo.get_paths(node1, node2, relationships, depth=3, algorithm="allPaths") # finds all paths between two nodes
122336a @heelhook Update README.rdoc
heelhook authored
166 @neo.get_shortest_weighted_path(node1, node2, relationships, # find the shortest path between two nodes
167 weight_attr='weight', depth=2, # accounting for weight in the relationships
168 algorithm='dijkstra') # using 'weight' as the attribute
c3a00a0 @maxdemarzi added find_id and cleaned up tests
maxdemarzi authored
169
170 nodes = @neo.traverse(node1, # the node where the traversal starts
4d0c88a @maxdemarzi readme changes
maxdemarzi authored
171 "nodes", # return_type "nodes", "relationships" or "paths"
90cb6ed @maxdemarzi adding traverser
maxdemarzi authored
172 {"order" => "breadth first", # "breadth first" or "depth first" traversal order
173 "uniqueness" => "node global", # See Uniqueness in API documentation for options.
174 "relationships" => [{"type"=> "roommates", # A hash containg a description of the traversal
175 "direction" => "all"}, # two relationships.
176 {"type"=> "friends", #
177 "direction" => "out"}], #
178 "prune evaluator" => {"language" => "javascript", # A prune evaluator (when to stop traversing)
80cc0f0 @peterneubauer typos
peterneubauer authored
179 "body" => "position.endNode().getProperty('age') < 21;"},
90cb6ed @maxdemarzi adding traverser
maxdemarzi authored
180 "return filter" => {"language" => "builtin", # "all" or "all but start node"
181 "name" => "all"},
182 "depth" => 4})
183
184 # "depth" is a short-hand way of specifying a prune evaluator which prunes after a certain depth.
185 # If not specified a depth of 1 is used and if a "prune evaluator" is specified instead of a depth, no depth limit is set.
186
92ce780 @maxdemarzi more batching functions
maxdemarzi authored
187 @neo.batch [:get_node, node1], [:get_node, node2] # Gets two nodes in a batch
188 @neo.batch [:create_node, {"name" => "Max"}],
189 [:create_node, {"name" => "Marc"}] # Creates two nodes in a batch
190 @neo.batch [:set_node_property, node1, {"name" => "Tom"}],
191 [:set_node_property, node2, {"name" => "Jerry"}] # Sets the property of two nodes
208b317 @maxdemarzi adding create unique relationship to batch
maxdemarzi authored
192 @neo.batch [:create_unique_node, index_name, key, value,
193 {"age" => 33, "name" => "Max"}] # Creates a unique node
65b53b2 @heelhook Update README.rdoc
heelhook authored
194 @neo.batch [:get_node_relationships, node1, "out",
195 [:get_node_relationships, node2, "out"] # Get node relationships in a batch
92ce780 @maxdemarzi more batching functions
maxdemarzi authored
196 @neo.batch [:get_relationship, rel1],
197 [:get_relationship, rel2] # Gets two relationships in a batch
198 @neo.batch [:create_relationship, "friends",
eb03523 @maxdemarzi batch arrays of arrays
maxdemarzi authored
199 node1, node2, {:since => "high school"}],
92ce780 @maxdemarzi more batching functions
maxdemarzi authored
200 [:create_relationship, "friends",
201 node1, node3, {:since => "college"}] # Creates two relationships in a batch
208b317 @maxdemarzi adding create unique relationship to batch
maxdemarzi authored
202 @neo.batch [:create_unique_relationship, index_name,
203 key, value, "friends", node1, node2] # Creates a unique relationship
f4b31eb @maxdemarzi adding get_node_index and get_relationship_index to batch
maxdemarzi authored
204 @neo.batch [:get_node_index, index_name, key, value] # Get node index
205 @neo.batch [:get_relationship_index, index_name, key, value] # Get relationship index
206
8f15c03 @maxdemarzi adding more batching functions, now with referencing
maxdemarzi authored
207 @neo.batch [:create_node, {"name" => "Max"}],
208 [:create_node, {"name" => "Marc"}], # Creates two nodes and index them
eb03523 @maxdemarzi batch arrays of arrays
maxdemarzi authored
209 [:add_node_to_index, "test_node_index", key, value, "{0}"],
210 [:add_node_to_index, "test_node_index", key, value, "{1}"],
8f15c03 @maxdemarzi adding more batching functions, now with referencing
maxdemarzi authored
211 [:create_relationship, "friends", # and create a relationship for those
eb03523 @maxdemarzi batch arrays of arrays
maxdemarzi authored
212 "{0}", "{1}", {:since => "college"}], # newly created nodes
8f15c03 @maxdemarzi adding more batching functions, now with referencing
maxdemarzi authored
213 [:add_relationship_to_index,
214 "test_relationship_index", key, value, "{4}"] # and index the new relationship
215
eb03523 @maxdemarzi batch arrays of arrays
maxdemarzi authored
216 @neo.batch *[[:create_node, {"name" => "Max"}],
217 [:create_node, {"name" => "Marc"}]] # Use the Splat (*) with Arrays of Arrays
218
8f15c03 @maxdemarzi adding more batching functions, now with referencing
maxdemarzi authored
219 See http://docs.neo4j.org/chunked/milestone/rest-api-batch-ops.html for Neo4j Batch operations documentation.
92ce780 @maxdemarzi more batching functions
maxdemarzi authored
220
3313e4a @maxdemarzi adding tests and readme for unique nodes and relationships
maxdemarzi authored
221
222 Please see the specs for more examples.
223
224
8e66583 @maxdemarzi started addeding fake bulk operations
maxdemarzi authored
225 Experimental:
226
227 nodes = @neo.create_nodes(5) # Create 5 empty nodes
228 nodes = @neo.create_nodes_threaded(5) # Create 5 empty nodes using threads
229 nodes = @neo.create_node_nodes([{"age" => 31, "name" => "Max"},
230 {"age" => 24, "name" => "Alex"}) # Create two nodes with properties
231 nodes = @neo.create_node_nodes_threaded([{"age" => 31, "name" => "Max"},
232 {"age" => 24, "name" => "Alex"}) # Create two nodes with properties threaded
233 nodes = @neo.get_nodes([17,86,397,33]) # Get four nodes by their id
234
235 one_set_nodes = @neo.create_nodes(3)
236 another_node = @neo.create_node("age" => 31, "name" => "Max")
237 nodes = @neo.get_nodes([one_set_nodes, another_node]) # Get four nodes
238
ab853ae @maxdemarzi quick initializer
maxdemarzi authored
239 === Phase 2
7b90ece @maxdemarzi starting phase 2
maxdemarzi authored
240
74204e8 @maxdemarzi adding relationship tests
maxdemarzi authored
241 Trying to mimic the Neo4j.rb API.
242
7b90ece @maxdemarzi starting phase 2
maxdemarzi authored
243 Now we are returning full objects. The properties of the node or relationship can be accessed directly (node.name).
244 The Neo4j ID is available by using node.neo_id .
245
49fe9ac @maxdemarzi adding authentication options, fixing index tests
maxdemarzi authored
246 @neo2 = Neography::Rest.new ({:server => '192.168.10.1'})
7b90ece @maxdemarzi starting phase 2
maxdemarzi authored
247
74204e8 @maxdemarzi adding relationship tests
maxdemarzi authored
248 Neography::Node.create # Create an empty node
249 Neography::Node.create("age" => 31, "name" => "Max") # Create a node with some properties
250 Neography::Node.create(@neo2, {"age" => 31, "name" => "Max"}) # Create a node on the server defined in @neo2
251 Neography::Node.create({"age" => 31, "name" => "Max"}, @neo2) # Same as above, but different order
252
253 Neography::Node.load(5) # Get a node and its properties by id
254 Neography::Node.load(existing_node) # Get a node and its properties by Node
255 Neography::Node.load("http://localhost:7474/db/data/node/2") # Get a node and its properties by String
256
257 Neography::Node.load(@neo2, 5) # Get a node on the server defined in @neo2
258 Neography::Node.load(5, @neo2) # Same as above, but different order
259
260 n1 = Node.create
261 n1.del # Deletes the node
262 n1.exist? # returns true/false if node exists in Neo4j
263
264 n1 = Node.create("age" => 31, "name" => "Max")
265 n1[:age] #returns 31 # Get a node property using [:key]
266 n1.name #returns "Max" # Get a node property as a method
267 n1[:age] = 24 # Set a node property using [:key] =
268 n1.name = "Alex" # Set a node property as a method
269 n1[:hair] = "black" # Add a node property using [:key] =
270 n1.weight = 190 # Add a node property as a method
271 n1[:name] = nil # Delete a node property using [:key] = nil
272 n1.name = nil # Delete a node property by setting it to nil
4541ce9 @maxdemarzi property deletion
maxdemarzi authored
273
74204e8 @maxdemarzi adding relationship tests
maxdemarzi authored
274 n2 = Neography::Node.create
275 new_rel = Neography::Relationship.create(:family, n1, n2) # Create a relationship from my_node to node2
276 new_rel.start_node # Get the start/from node of a relationship
277 new_rel.end_node # Get the end/to node of a relationship
da88fba @maxdemarzi More Phase 2 Functionality
maxdemarzi authored
278 new_rel.other_node(n2) # Get the other node of a relationship
5a83e3a @heelhook document and fix wrong variable access
heelhook authored
279 new_rel.attributes # Get the attributes of the relationship as an array
da88fba @maxdemarzi More Phase 2 Functionality
maxdemarzi authored
280
74204e8 @maxdemarzi adding relationship tests
maxdemarzi authored
281 existing_rel = Neography::Relationship.load(12) # Get an existing relationship by id
282 existing_rel.del # Delete a relationship
283
284 Neography::Relationship.create(:friends, n1, n2)
d3c4887 @maxdemarzi adding to documentation
maxdemarzi authored
285 n1.outgoing(:friends) << n2 # Create outgoing relationship
286 n1.incoming(:friends) << n2 # Create incoming relationship
287 n1.both(:friends) << n2 # Create both relationships
288
289 n1.outgoing # Get nodes related by outgoing relationships
290 n1.incoming # Get nodes related by incoming relationships
291 n1.both # Get nodes related by any relationships
292
293 n1.outgoing(:friends) # Get nodes related by outgoing friends relationship
294 n1.incoming(:friends) # Get nodes related by incoming friends relationship
295 n1.both(:friends) # Get nodes related by friends relationship
296
da88fba @maxdemarzi More Phase 2 Functionality
maxdemarzi authored
297 n1.outgoing(:friends).incoming(:enemies) # Get nodes related by one of multiple relationships
298 n1.outgoing(:friends).depth(2) # Get nodes related by friends and friends of friends
299 n1.outgoing(:friends).depth(:all) # Get nodes related by friends until the end of the graph
300 n1.outgoing(:friends).depth(2).include_start_node # Get n1 and nodes related by friends and friends of friends
301
302 n1.outgoing(:friends).prune("position.endNode().getProperty('name') == 'Tom';")
303 n1.outgoing(:friends).filter("position.length() == 2;")
304
74204e8 @maxdemarzi adding relationship tests
maxdemarzi authored
305 n1.rel?(:friends) # Has a friends relationship
306 n1.rel?(:outgoing, :friends) # Has outgoing friends relationship
307 n1.rel?(:friends, :outgoing) # same, just the other way
308 n1.rel?(:outgoing) # Has any outgoing relationships
309 n1.rel?(:both) # Has any relationships
310 n1.rel?(:all) # same as above
311 n1.rel? # same as above
4e0087d @maxdemarzi Phase 2: Starting on Relationships
maxdemarzi authored
312
da88fba @maxdemarzi More Phase 2 Functionality
maxdemarzi authored
313 n1.rels # Get node relationships
314 n1.rels(:friends) # Get friends relationships
315 n1.rels(:friends).outgoing # Get outgoing friends relationships
316 n1.rels(:friends).incoming # Get incoming friends relationships
317 n1.rels(:friends,:work) # Get friends and work relationships
318 n1.rels(:friends,:work).outgoing # Get outgoing friends and work relationships
0dd7b47 @maxdemarzi adding Node Paths
maxdemarzi authored
319
320 n1.all_paths_to(n2).incoming(:friends).depth(4) # Gets all paths of a specified type
321 n1.all_simple_paths_to(n2).incoming(:friends).depth(4) # for the relationships defined
322 n1.all_shortest_paths_to(n2).incoming(:friends).depth(4) # at a maximum depth
323 n1.path_to(n2).incoming(:friends).depth(4) # Same as above, but just one path.
324 n1.simple_path_to(n2).incoming(:friends).depth(4)
325 n1.shortest_path_to(n2).incoming(:friends).depth(4)
326
327 n1.shortest_path_to(n2).incoming(:friends).depth(4).rels # Gets just relationships in path
328 n1.shortest_path_to(n2).incoming(:friends).depth(4).nodes # Gets just nodes in path
329
8e66583 @maxdemarzi started addeding fake bulk operations
maxdemarzi authored
330
ab93266 @maxdemarzi doc updates
maxdemarzi authored
331 See Neo4j API for:
332 * {Order}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/Traverser.Order.html]
333 * {Uniqueness}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/kernel/Uniqueness.html]
334 * {Prune Evaluator}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/StopEvaluator.html]
335 * {Return Filter}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/ReturnableEvaluator.html]
90cb6ed @maxdemarzi adding traverser
maxdemarzi authored
336
34068ab @maxdemarzi adding examples and get_relationship
maxdemarzi authored
337 === Examples
338
49fe9ac @maxdemarzi adding authentication options, fixing index tests
maxdemarzi authored
339 A couple of examples borrowed from Matthew Deiters's Neo4jr-social:
34068ab @maxdemarzi adding examples and get_relationship
maxdemarzi authored
340
341 * {Facebook}[https://github.com/maxdemarzi/neography/blob/master/examples/facebook.rb]
342 * {Linked In}[https://github.com/maxdemarzi/neography/blob/master/examples/linkedin.rb]
343
49fe9ac @maxdemarzi adding authentication options, fixing index tests
maxdemarzi authored
344 Phase 2 way of doing these:
345
346 * {Facebook}[https://github.com/maxdemarzi/neography/blob/master/examples/facebook_v2.rb]
347 * {Linked In}[https://github.com/maxdemarzi/neography/blob/master/examples/linkedin_v2.rb]
348
7fddfc9 @nickflux Added clean_database to Rest module
nickflux authored
349 === Testing
350
351 To run testing locally you will need to have two instances of the server running. There is some
352 good advice on how to set up the a second instance on the
353 {neo4j site}[http://docs.neo4j.org/chunked/stable/server-installation.html#_multiple_server_instances_on_one_machine].
354 Connect to the second instance in your testing environment, for example:
355
356 if Rails.env.development?
357 @neo = Neography::Rest.new({:port => 7474})
358 elsif Rails.env.test?
359 @neo = Neography::Rest.new({:port => 7475})
360 end
361
362 Install the test-delete-db-extension plugin, as mentioned in the neo4j.org docs, if you want to use
363 the Rest clean_database method to empty your database between tests. In Rspec, for example,
364 put this in your spec_helper.rb:
365
366 config.before(:each) do
367 @neo.clean_database("yes_i_really_want_to_clean_the_database")
368 end
49fe9ac @maxdemarzi adding authentication options, fixing index tests
maxdemarzi authored
369
4e1cf8f @maxdemarzi documentation changes, use shortest path as default for path
maxdemarzi authored
370 === To Do
371
0e3b309 @maxdemarzi adding travis build status as well as contributing and help sections to ...
maxdemarzi authored
372 * Batch functions
49fe9ac @maxdemarzi adding authentication options, fixing index tests
maxdemarzi authored
373 * Phase 2 Index functionality
da88fba @maxdemarzi More Phase 2 Functionality
maxdemarzi authored
374 * More Tests
375 * More Examples
376 * Mixins ?
4e1cf8f @maxdemarzi documentation changes, use shortest path as default for path
maxdemarzi authored
377
0e3b309 @maxdemarzi adding travis build status as well as contributing and help sections to ...
maxdemarzi authored
378 === Contributing
379
380 {<img src="https://secure.travis-ci.org/maxdemarzi/neography.png" />}[http://travis-ci.org/maxdemarzi/neography]
381
382 Please create a {new issue}[https://github.com/maxdemarzi/neography/issues] if you run into any bugs.
383 Contribute patches via pull requests.
384
385 === Help
386
f16ecb6 @maxdemarzi Whoa... can't believe I had my email address wrong on the readme for so ...
maxdemarzi authored
387 If you are just starting out, or need help send me an e-mail at maxdemarzi@gmail.com.
388 Check you my blog at http://maxdemarzi.com where I have more Neography examples.
0e3b309 @maxdemarzi adding travis build status as well as contributing and help sections to ...
maxdemarzi authored
389
da88fba @maxdemarzi More Phase 2 Functionality
maxdemarzi authored
390 === Licenses
2bedc62 @maxdemarzi adding indexes
maxdemarzi authored
391
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
392 * Neography - MIT, see the LICENSE file http://github.com/maxdemarzi/neography/tree/master/LICENSE.
393 * Lucene - Apache, see http://lucene.apache.org/java/docs/features.html
90cb6ed @maxdemarzi adding traverser
maxdemarzi authored
394 * Neo4j - Dual free software/commercial license, see http://neo4j.org
0b5b547 @maxdemarzi starting on relationships
maxdemarzi authored
395
396
Something went wrong with that request. Please try again.