MATCH (a:CALL)-[:RECEIVED_CALL]->(b:PERSON),(c:CALL) <-[:MADE_CALL]-(d:PERSON)
WHERE id(a) < 80 and id(c) < 80
WITH COLLECT([b,d]) as calls
UNWIND calls as callss
FOREACH (i IN callss | CREATE (d)-[r:KNOWS]->(b))
RETURN callss
Hello @iamtienng and welcome to the Neo4j community
MATCH (a:CALL)-[:RECEIVED_CALL]->(b:PERSON)
MATCH (c:CALL)<-[:MADE_CALL]-(d:PERSON)
WHERE id(a) < 80 AND id(c) < 80
WITH DISTINCT b, d
CREATE (d)-[r:KNOWS]->(b)
UNWIND range(0, 100) as idf
MATCH (a:CALL)-[:RECEIVED_CALL]->(b:PERSON),(c:CALL) <-[:MADE_CALL]-(d:PERSON)
WHERE id(a)=idf and id(c)=idf
CREATE (d)-[r:KNOWS]->(b)
RETURN a,b,c,d
Usage of graph ids like this isn't recommended. If a node is deleted, its id becomes eligible for reuse in the future, so an approach like this doesn't have many guarantees about the nodes it will operate over.
What is weird here is that your query seems more complex than it needs to be, and it obscures what you're trying to do.
Your latest query shows that the calls a and c are actually the same node, since your restriction is that they have the same graph id. This is the same call! If all you're trying to do is MATCH to the caller and receiver of the same call and create a :KNOWS relationship between them, then we can do this far more clearly we just use a single CALL node:
MATCH (d:PERSON)-[:MADE_CALL]->(c:CALL)-[:RECEIVED_CALL]->(b:PERSON)
MERGE (d)-[:KNOWS]->(b)
RETURN d, c, b
Your solution is so simple but yet extremely effective. Maybe I have not fully understood how Neo4j works.
Thank you so much for the replies even though I haven't logged in in a long time.