maxdemarzi / neography

A thin Ruby wrapper to the Neo4j Rest API
MIT License
602 stars 135 forks source link

I am using Phase2 to get related nodes...where can I find docs on the methods? #219

Closed angelacode closed 7 years ago

angelacode commented 7 years ago

grateful_nodes = node.outgoing(:gratefulFor) `grateful_nodes.methods'

The list includes things like: How do I find the usage or definitions I know some of these things seem similar to methods for an array.

But I am interested in filter and uniqueness, for example.

:uniqueness,
 :uniqueness=,
 :depth,
 :depth=,
 :prune,
 :prune=,
 :filter,
 :filter=,
 :relationships,
 :relationships=,
 :<<,
 :create,
 :both,
 :outgoing,
 :incoming,
 :include_start_node,
 :size,
 :length,
 :[],
 :empty?,
 :each,
 :iterator,
 :to_a,
 :entries,
 :to_h,
 :sort,
 :sort_by,
 :grep,
 :count,
 :find,
 :detect,
angelacode commented 7 years ago

Hi, I am following up on the documentation, it's still not clear what I am getting back:

n1.outgoing # Get nodes related by outgoing relationships n1.incoming # Get nodes related by incoming relationships n1.both # Get nodes related by any relationships

The output should be nodes, but I get Neography:RelationshipTraversal.

maxdemarzi commented 7 years ago

You may want to just use Cypher queries instead of trying to use the traversal api. @neo.execute_query("MATCH (n) RETURN n LIMIT 25")

What you are seeing is a traversal being built along the lines of https://github.com/maxdemarzi/neography/blob/afb3a4724e67d6665d79ca280bb709e69814e893/lib/neography/node_traverser.rb

Once you finish describing the traverser, you need to .each to get the answers.

See: https://github.com/maxdemarzi/neography/blob/afb3a4724e67d6665d79ca280bb709e69814e893/examples/linkedin_v2.rb

johnathan.all_simple_paths_to(mary).incoming(:friends).depth(4).nodes.each do |node|
  puts node.map{|n| n.name }.join(' => friends => ')
end