Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-26-2019 04:55 PM
There are examples of creating multiple nodes
CREATE
(:Person {name: 'Michael Caine', born: 1933}),
(:Person {name: 'Liam Neeson', born: 1952}),
(:Person {name: 'Katie Holmes', born: 1978}),
(:Person {name: 'Benjamin Melniker', born: 1913})
in the "Creating Data" section and if you put this into the desktop browser the code will run,
but I have yet to figure out what the equivalent MERGE statements need to be to create relationships across different nodes.
MATCH (p:Person), (m:Movie) WHERE m.title = 'Batman Begins' AND p.name ENDS WITH 'Caine' MERGE (p)-[:ACTED_IN]->(m)
RETURN p, m
If I copy multiple merge statements like the CREATE statement above an error message is returned.
How do I list a whole lot of MERGE commands for different nodes?
Please be patient- just learning baby steps.
06-27-2019 05:25 AM
With CREATE, you can create multiple nodes and relationships. With MERGE, you can only create one node or set of nodes with their respective relationships.
To perform MERGE, you must either provide enough information for the node to be able to create it (for example a property value that perhaps has a uniqueness index on it), or it must have a reference from a previous MATCH statement.
So, for example, you can create the node and then use MERGE to add the relationships:
CREATE (p:Person {name: 'xxx'}),
(m:Movie {title: 'yyy'})
MERGE (p)-[:ACTED_IN]->(m)
MERGE (p)-[:DIRECTED]->(m)
Elaine
All the sessions of the conference are now available online