Category Archives: Database

Neo4j Query Tutorial – MATCH and MERGE

Neo4j Query Tutorial - MATCH and MERGE

Neo4j Query Tutorial – MATCH and MERGE

Neo4j Query Tutorial - MATCH and MERGE

Example 1: Match two nodes and create a relationship between them. MATCH (person1:LABEL{id:’1234′}),(person2:LABEL{id:’5678′}) MERGE (person1)-[r:FRIEND]-(person2) Example 2: Match two nodes and create/update a relation between them. Optionally set properties to the nodes or relationships with ON CREATE SET or ON MATCH SET. Use r+={property:’value’} to add properties or update existing properties. MATCH (user1:USER{id:’123′}),(user2:USER{id:’456′}) MERGE (user1)-[r:FRIEND]-(user2) ON CREATE SET… Read More »