release 2.0.0.alpha.7

23 views
Skip to first unread message

Andreas Ronge

unread,
Apr 19, 2012, 4:19:20 PM4/19/12
to neo...@googlegroups.com
Hi

New release. It contains one new cool featue (issue 181) - combining
cypher DSL with rules.
I have written some documentation about it here, see the Cypher and
Rules section at the wiki page:
https://github.com/andreasronge/neo4j/wiki/Neo4j%3A%3AWrapper-Rules-and-Functions
and how to write Cypher DSL queries -
https://github.com/andreasronge/neo4j/wiki/Neo4j%3A%3ACore-Cypher

Cheers
Andreas

== 2.0.0.alpha.7 / 2012-04-19
* fix for Neo4j::Config bug - did not work from rails to set the db
location, closes #191
* has_n and has_one method generate class method returning the name of
the relationship as a Symbol, closes #170
* Raise exception if trying to index boolean property, closes #180
* Made start_node= and end_node= protected closes 186
* Support for things like dungeon.monsters.dangerous { |m| m[:weapon?]
== 'sword' } closes #181

Peter Neubauer

unread,
Apr 19, 2012, 4:27:04 PM4/19/12
to neo...@googlegroups.com
Wow Andreas and friends,
that Cypher DSL does look beautiful!

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

If you can write, you can code - @coderdojomalmo
If you can sketch, you can use a graph database - @neo4j

> --
> You received this message because you are subscribed to the Google Groups "neo4jrb" group.
> To post to this group, send email to neo...@googlegroups.com.
> To unsubscribe from this group, send email to neo4jrb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
>

Cyprian Kowalczyk

unread,
Apr 20, 2012, 2:41:47 AM4/20/12
to neo...@googlegroups.com
How do I translate the following query to Cypher DSL:

       Neo4j._query("
         START u=node({user_id}), p=node({place_id}) 
         MATCH 
          u-[:`User#rc`]->rc<-[:`RS#rc`]-rs<-[:`Place#rs`]-p,
          rc<-[:active]-()
         WHERE rc._classname ?= 'RC' 
         RETURN rc", 
         :user_id => self.neo_id,
         :place_id => place.neo_id
       )

Andreas Ronge

unread,
Apr 20, 2012, 8:17:20 AM4/20/12
to neo...@googlegroups.com
I have made it a little bit easier to use model object with cypher,
for example added a is_a? method, see
https://github.com/andreasronge/neo4j/issues/193
This make it possible to write the query like this:

Neo4j.query(user, place) do |u, p|
rc = node(:rc)
u > rel(User.rc) > rc < rel(Place.rs) < p
rc < rel(:active) < node
rc.is_a?(RC)
rc
end

> --
> You received this message because you are subscribed to the Google Groups
> "neo4jrb" group.

> To view this discussion on the web visit
> https://groups.google.com/d/msg/neo4jrb/-/j4JCQPler9kJ.

Cyprian Kowalczyk

unread,
Apr 20, 2012, 9:42:17 AM4/20/12
to neo...@googlegroups.com
There is one relation missing in your code, should be:
u-[:`User#rc`]->rc<-[:`RS#rc`]-rs<-[:`Place#rs`]-p
and you have
u-[:`User#rc`]->rc<-[:`Place#rs`]-p

Here is my example fully rewritten, if I'm correct:
       res = Neo4j.query(self, place) do |u, p|
         rc = node(:rc)
         rs = node(:rs)
         u > rel(User.rc) > rc < rel(RS.rc) < rs < rel(Place.rs) < p
         rc < rel(:active) < node
         rc.is_a?(RC) 
         rc
       end

I'm using it inside a model so self==user, but Cypher complains with the following error:

NativeException:
       org.neo4j.cypher.SyntaxException: expected node id, or *
       "START n0=node(),n1=node(4) MATCH (n0)-[]->(rc)<-[]-(rs)<-[]-(n1),(rc)<-[]-(v6) RETURN rc"
                                 ^
I'm also wondering why the relation square brackets are empty.

Any ideas?


On 20 kwi 2012, at 14:17, Andreas Ronge wrote:

I have made it a little bit easier to use model object with cypher,
for example added a is_a? method, see
https://github.com/andreasronge/neo4j/issues/193
This make it possible to write the query like this:

Neo4j.query(user, place) do |u,  p|
 rc = node(:rc)
 u > rel(User.rc) > rc < rel(Place.rs) < p
 rc < rel(:active) < node
 rc.is_a?(RC)
 rc
end

Cyprian Kowalczyk

unread,
Apr 20, 2012, 10:28:38 AM4/20/12
to neo...@googlegroups.com

Cyprian Kowalczyk

unread,
Apr 20, 2012, 10:46:16 AM4/20/12
to neo...@googlegroups.com
All fixed in neo4j-core master.
Reply all
Reply to author
Forward
0 new messages