Create relationship from two labels

Hi,

I am new to Neo4J.

I have two labels in one database: node_list and edge_list. The keys in node_list are: {ID, author, time_stamp,,,,}. The keys in edge_list are {from_ID, to _ID}.

ID and from_ID, to_ID are in the same format.

Now I want to create the relationship among the node_list IDs based on the relationship defined in the edge_list. I had tried:
MATCH (p1: node_list{ID}) (p2: node_list{ID}) (edge:edge_list)
MERGE (p1)-[r:point_to]->(p2)
ON p1 = edge.from_ID and p2=edge.to_ID

However, it does not work. Can anyone help me figure out how to create this relationship? Thank you very much.

Best
Harbing

Add RETURN r after ON p1 = edge.from_ID and p2=edge.to_ID ?

link: https://www.quackit.com/neo4j/tutorial/neo4j_create_a_relationship_using_cypher.cfm

It still give me the following error after adding RETURN r:

Invalid input '(': expected whitespace, comment, a relationship pattern, ',', USING, WHERE, FROM GRAPH, CONSTRUCT, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE UNIQUE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 1, column 33 (offset: 32))
"MATCH (p1: node_list{ID}) (p2: node_list{ID}) (edge:edge_list)"

So, try this:

MATCH (p1: node_list{ID}),(p2: node_list{ID}),(edge:edge_list)
MERGE (p1)-[r:point_to]->(p2)
ON p1 = edge.from_ID and p2=edge.to_ID
RETURN r

I still got the following error sign by running the code:

MATCH (p1: node_list{ID}),(p2: node_list{ID}),(edge:edge_list)
MERGE (p1)-[r:point_to]->(p2)
ON p1 = edge.from_ID and p2=edge.to_ID
RETURN r

Return:

Invalid input 'p': expected whitespace, comment, MATCH or CREATE (line 3, column 4 (offset: 108))
"ON p1 = edge.from_ID and p2=edge.to_ID"
     ^

I think I haven't understood the philosophy of Cypher yet. In my case, I want to create relationships within my node_list from a seperate labels that only stores the relationships. I guess this should be similar with the friendship type of networks. Is there any similar case study on social network applications that I can borrow? Thanks.

Let's start working with Sandboxes prepared by Neo4j.
Next try build you Graph form CREATE nodes, and CREATE relation (check correct of you Nodes/Relation etc."
Next learn more about MERGE.

Of course, I can get you answer, but I know from my exp that is too lazy way.

I would familiarise yourself with nodes, aliases and properties. you are getting tripped up at the ON section comparing a node to a property.

If you want to know what a working query would look like see below:

match (n:node_list) match (m:node_list) match (e:edge_list) Matches nodes
where n.ID = e.from_ID and m.ID = e.to_ID Validates criteria note node.property structure e.g. n is node and id is property, originally you were comparing the edge property to the p1 node
merge (n)-[r:point_to]->(m) produces relationships
return n,m,r returns results

Thanks. Now it works.

I think what got me confused was the MATCH (p1: node_list{ID}). I though node{property} is already making n referring to the specific property. But apparently it is not. Thanks for clarifying it.

Best
Harbing