Re: [Neo4j] Changing relationship type in Neo4j

688 views
Skip to first unread message

Marko Rodriguez

unread,
Nov 13, 2012, 2:26:27 PM11/13/12
to ne...@googlegroups.com
Hi,

You have to delete the edge and create a new one.

You can change a "status" property on the edge if you want as property key/values are mutable.

e.status = 'its complicated'

HTH,
Marko.


On Nov 13, 2012, at 10:45 AM, Mateusz Kieblesz wrote:

Hello,

Sorry in advance - it look like a newbie question :)

is there is possible way to change relationship status/label?? I tried to do this with gremlin:

  • gremlin> e = g.e(10)
  • ==> e[10][9-->10]
  • gremlin> e.label
  • ==> 
  • gremlin> e = g.e(14)
  • ==> e[14][8-next->13]
  • gremlin> e.label
  • ==> next
  • gremlin> e.label='is_in'
  • ==> Cannot set readonly property: label for class: com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jEdge

The solution to delete relationship and create new one with desired relationship label (in this case 'next') is a little bit cunterintuitive. I will be gratefull to someone for providing me an answer.

--
 
 

Sébastien Heymann

unread,
Jul 19, 2013, 1:09:50 PM7/19/13
to ne...@googlegroups.com, okram...@gmail.com
+1 for changing relationship type without the burden of re-creating it.

Nicholas Stuart

unread,
Jul 21, 2013, 11:41:25 AM7/21/13
to ne...@googlegroups.com, okram...@gmail.com
This shouldn't be that difficult. At the store level, a relationship just has a reference to the relationship type id, so it should just be a matter of changing that ID into what you want. I agree that this would be a handy feature to have.

Nigel Small

unread,
Jul 21, 2013, 11:59:41 AM7/21/13
to Neo4J, okram...@gmail.com
Relationships are immutable by design and that is very unlikely to change as this is fundamental to the design of Neo4j. Among other things, this allows matching to be carried out efficiently within the database engine.


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dmitry Paranyushkin

unread,
Jan 25, 2014, 8:01:07 AM1/25/14
to ne...@googlegroups.com, okram...@gmail.com
Hey Nigel,

How would adding a feature to change the relationship affect its ability to perform matching?

I mean I understand that it would be not the most trivial function to have, but in the end I don't see how it's different to change the relationships as opposed to deleting them and making the new ones again... 

Will appreciate if you can explain, so I can better understand the logic behind it.

Thanks!

Zach

unread,
Nov 18, 2014, 1:21:40 PM11/18/14
to ne...@googlegroups.com
The "delete then create a new one" approach is not only counter-intuitive, it but also changes the id of the relationship.
If an application use internal IDs externally as a unique identifier (I assume neo4j 2.*, which disabled ID reuse, allows doing so now), this means lots of extra work and potential errors.
Reply all
Reply to author
Forward
0 new messages