3

I would like to find all paths between two nodes in my graph using neo4j.rb

I know how to write a cypher query for the same and the following source https://github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3ACore-Traverse indicates an "outgoing" function.

But

a = SomeNodeClass.find_by(someattrr: 'someval')
a.outgoing(:somerel).paths.to dest

Throws an error: undefined method outgoing for SomeNodeClass:0x007fd787dd9080

Where SomeNodeClass is defined as mentioned in neo4j.rb by adding

include Neo4j::ActiveNode

Does anyone know if there is a way to write direct cypher queries using neo4j.rb since the _query method no longer seems to be supported.

Can anyone help the documentation doesn't seem to be of much help here.

Artemis Fowl
  • 301
  • 1
  • 10

1 Answers1

2

That page is part of the legacy, deprecated documentation from a few years ago. There is newer documentation in the sidebar towards the top but the project has been migrating all of its docs to http://neo4jrb.readthedocs.org/en/5.2.x/.

Where direct Cypher queries are concerned, the DSL is in the Neo4j-core gem, https://github.com/neo4jrb/neo4j-core. The wiki there covers the basics and the shared query spec is full of small examples of methods and their output.

As far as I know, neither the Neo4j gem nor Neo4j-core provide objects or great options for working with paths at the moment, so writing Cypher seems like your best bet. There is a new Neo4j::Core::Path class defined here that will be part of a coming release. Brian, the other maintainer, has been working on that, so he might chime in with more information. You can also pop into the Ruby room on the Neo4j Slack channel or the Gitter room for help during the day. There are usually a few people hanging out in there who are eager to help.

subvertallchris
  • 5,282
  • 2
  • 25
  • 43
  • 1
    Thanks a lot, i can't upvote since i only have 14 rep, but i have marked your answer as accepted. – Artemis Fowl Oct 09 '15 at 17:53
  • 1
    I foresee heavy usage of path computations and plan to use the neo4j database to full effect. Would be possible to do all of that using cypher queries in neo4j-core. Are there any options available for ruby? – Artemis Fowl Oct 09 '15 at 20:07
  • When the new release happens, the `Path` class [here](https://github.com/neo4jrb/neo4j-core/blob/master/lib/neo4j/core/path.rb) might help you do a bit more in Ruby. You might want to pop into the Slack room and see if anyone there can give you advice. I've never had to do anything with paths but I'm sure someone has. Worst comes to worst, Brian Underwood is the maintainer who's adding the path stuff to the gem, he's usually in Slack during the week but is on vacation until Monday or Tuesday. – subvertallchris Oct 09 '15 at 21:20
  • If there are some specific additions to the gems that you think would be helpful when working with paths, we're always open to requests and contributions, too. We can help you get started if you do want to get involved. – subvertallchris Oct 09 '15 at 21:22