简体   繁体   中英

how to combine two nodes with different properties merge as one node in cypher?

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM