1
votes

how will I combine two nodes with different properties and merge as one node in cypher?

example node 1 has property of name with value of name1 and node 2 has property of classification and value of class1 to be merge as one node,combining the two properties

tnx

2

2 Answers

1
votes

I'm pretty sure that this is not currently possible dynamically, but if you know what properties you're transferring:

MATCH (a:Label), (b:Label)
WHERE <something about a and b>
SET a.constraint = b.constraint, a.other_prop = b.other_prop
DELETE b // If you want do delete b

Otherwise I'd suggest using Cypher to load the objects, merge the properties in memory, and then make a query to save the result. I'd suggest checking out the SET clause and the += operator (here which can take a Map (Hash/Dictionary/whatever) and append all of the given properties that way.

1
votes

i think it will be possible

see http://neo4j.com/docs/stable/query-set.html

MATCH (at { name: 'Andres' }),(pn { name: 'Peter' })
SET at = pn
RETURN at, pn

Use += if you don't want to delete the properties of the first node.