Getting relationships between nodes with Cipher bug?

17 views
Skip to first unread message

Cyprian Kowalczyk

unread,
Mar 29, 2012, 3:05:36 PM3/29/12
to neo4jrb
Hello,

Node id=1 and node id=25 are connected with 3 relationships.

"START n=node(1) MATCH n-[r]->m RETURN r" returns 3 rels,
"START m=node(25) MATCH n-[r]->m RETURN r" returns 3 rels as well.
This however returns zero rels:
"START n=node(1),m=node(25) MATCH n-[r]->m RETURN r".
How come?


Thanks.

Michael Hunger

unread,
Mar 29, 2012, 4:07:58 PM3/29/12
to neo...@googlegroups.com
Interesting, which direction do the rels have 1-->25 ?

b/c START m=node(25) MATCH n-[r]->m RETURN r
shouldn't return anything if the rels are in the other direction.
try to return the end-node too
START m=node(25) MATCH n-[r]->m RETURN r,m

you can try to leave the direction arrow off:
> START n=node(1),m=node(25) MATCH n-[r]-m RETURN r,n,m

Michael

> --
> 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,
Mar 30, 2012, 2:59:11 AM3/30/12
to neo4jrb
Hi Michael,

Yes, the direction is 1-->25 and I had tried without the direction
arrow.
The relationships have been created inside Rails app and it reads them
correctly.
This of cours doesn't return anything:
"START m=node(25) MATCH n<-[r]-m RETURN r"

Any other ideas?

Thanks,
Cyprian

On Mar 29, 10:07 pm, Michael Hunger <michael.hun...@neotechnology.com>
wrote:

Peter Neubauer

unread,
Mar 30, 2012, 3:51:33 AM3/30/12
to neo...@googlegroups.com
Cyprian,
do you have the database somewhere? Would like to see it.

Cheers,

/peter neubauer

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

Neo4j                                - Graphs rule.
Program or be programmed - Computer Literacy for kids.
http://foocafe.org/#CoderDojo

Cyprian Kowalczyk

unread,
Mar 30, 2012, 3:53:56 AM3/30/12
to neo4jrb
Some more findings:
I created few relationships in Rails app, where all looks ok.
There is a relation (1)-->(5), I cannot get it with Cipher.
I checked what are other relations from these two nodes and I can see
that there are mysterious relationships of type "all" and "_all" to a
node that presents itself as "Node[2]".
I can get these rels like this:
"START n=node(2),m=node(1) MATCH n-[r?]-m RETURN r"
but not like this:
"START n=node(1),m=node(2) MATCH n-[r?]-m RETURN r"
Why these return different results, if there is no rels' direction
arrow?
And how come I cannot get rels between (1) and (5) in any way?…

Michael Hunger

unread,
Mar 30, 2012, 3:57:53 AM3/30/12
to neo...@googlegroups.com
It would be great if you could share the db with Peter and me (offline).

Thanks a lot

Michael

Peter Neubauer

unread,
Mar 30, 2012, 5:16:38 AM3/30/12
to neo...@googlegroups.com
Hi there,
I am getting the expected results with 1.7.M02:

neo4j-sh (0)$ START n=node(2),m=node(1) MATCH n-[r?]-m RETURN r
+-------------+
| r           |
+-------------+
| :_all[3] {} |
| :_all[1] {} |
| :all[2] {}  |
+-------------+
3 rows, 351.71 ms

neo4j-sh (0)$ START n=node(1),m=node(2) MATCH n-[r?]-m RETURN r
+-------------+
| r           |
+-------------+
| :_all[3] {} |
| :_all[1] {} |
| :all[2] {}  |
+-------------+
3 rows, 14.92 ms

Where the _all relationships come from I am not sure, looks like something the ruby bindings are creating for internal aggregation use?

/peter

Andreas Ronge

unread,
Mar 30, 2012, 8:18:04 AM3/30/12
to neo...@googlegroups.com
Yes, the _all relationships comes from the class node which in turn
has a relationship to the reference node (or multi tenancy node). Btw,
the _all relationships are created by default using the neo4j.rb rules
feature (you can create your own aggregation also, similar to scope in
ActiveRecord).

> --
> 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/-/qr0vCgy6SxsJ.

Reply all
Reply to author
Forward
0 new messages