getRelationships(RelationshipType... types)

1 view
Skip to first unread message

sumanth

unread,
Feb 23, 2010, 7:01:22 AM2/23/10
to neo...@googlegroups.com, su...@truesparrow.com

Hi,

I am newbie to neo4j and I am enjoying it.

I have started to create nodes, relationships and assigning properties to the nodes etc.
I've got a problem in accessing relationships of a node.

If 'knows = DynamicRelationshipType.withName("KNOWS")' is a relation defined.

When a relationship 'knows' is formed from node1 to node2, I should be able to access relationship of node1 by one of node1.getRelationships() or node1.getRelationships(knows, direction) or node1.getRelationships(direction) or node1.getRelationships(knows) methods. 

There is no problem with the first three, but the last method throws an error.
Error is:
         NameError: no getRelationships with arguments matching [class org.neo4j.graphdb.DynamicRelationshipType] on object #<#<Class:01xf38cf0>:0x1aa0a15>

From the documentation of node1.getRelationships(RelationshipType... types), I sense that 'types' is a little different from 'knows' .

Please help me understand how types needs to be passed to the method node1.getRelationships(RelationshipType... types).

Thanks,
T.Sumanth

Matt Deiters

unread,
Feb 23, 2010, 1:31:11 PM2/23/10
to neo...@googlegroups.com
Try

RelationshipType.instance('KNOWS') or RelationshipType.instances('KNOWS', "SOMETHING_ELSE")

you can also specify the direction like:

RelationshipType.outgoing('KNOWS')

Matt


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

sumanth

unread,
Feb 24, 2010, 2:53:27 AM2/24/10
to neo4jrb
Thank you Matt, will try and see if I can successfully do it. :)

> > neo4jrb+u...@googlegroups.com<neo4jrb%2Bunsu...@googlegroups.com >

sumanth

unread,
Feb 24, 2010, 6:15:52 AM2/24/10
to neo4jrb
Hi Matt,

I have tried the way you have mentioned, only to get the error like:

"undefined method `instance' for
Java::OrgNeo4jGraphdb::RelationshipType:Module"

I tried to get the relations of a node1 like
node1.getRelationships(RelationshipType.instance('KNOWS')).
Relationship 'KNOWS' id defined as knows =
DynamicRelationshipType.withName("KNOWS").

Please tell me, if I am doing anything wrong, or anything missing
there.

Thanks in advance,
Sumanth.

Reply all
Reply to author
Forward
0 new messages