Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Update or change value in cypher neo4j

Tags:

java

neo4j

cypher

Is there any update query in cypher using which we can update the property of any node or relationship ?
For e.g. I have following node and relationship:
NodeA-[r:relatedTo]-NodeB
where relatedTo is a relationship having properties like active or inactive

How can I change this property using cypher query ?

like image 271
A Gupta Avatar asked Jun 06 '13 13:06

A Gupta


People also ask

How do I change my relationship name in Neo4j?

You cannot rename an already existing relationship. You'd have to run through all relationships, create the new one in parallel (including all properties) and then remove the old one.

Can u relabel node in Neo4j?

You can change the nodes associated with a label but you can't change the type of a relationship. Conceptually, if you take your chicken out of one coop and put it in another you haven't altered the substance of the chicken.

Is Neo4j key-value?

(b) Use Neo4j, by creating a node per key-value setting the key and value as properties on the node, but there is no relationship other then having an index to group these nodes together, exposing the key of the key-value as the key on the index.

What is unwind in Neo4j?

With UNWIND , you can transform any list back into individual rows. These lists can be parameters that were passed in, previously collect -ed result or other list expressions. One common usage of unwind is to create distinct lists. Another is to create data from parameter lists that are provided to the query.


1 Answers

using SET keyword in cypher query, see http://docs.neo4j.org/chunked/snapshot/query-set.html . (Since I have not came across any update query in cypher like in other RDBMS)

NodeA-[r:relatedTo]-NodeB
try to set value by : SET r.<your property name>="<desired value>"; before returning any value from start n=node(...)... return n; query.

like image 53
A Gupta Avatar answered Sep 22 '22 14:09

A Gupta