Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-04-2020 12:35 AM
Hi Team,
I am writing a node js function which contains a cypher query to form a relation between two person node if they met each other. When they met decide by the exchange of Bluetooth packet.
Problem is when many Bluetooth packets received by server simultaneously, there are many MET relationship formed between two-person node.
My query look like this in psudo form
Match Person A with id X
Match Person B with id y
Optinal Match A and B has any MET relation in A-> B or B<-A
Then if no relation create A -[r:Met]-> B
if relation exist increse the count of met ( r.count++)
In any given case, there should be only one MET relationship in either A->B or B<-A.
Solved! Go to Solution.
05-09-2020 03:56 AM
I don't believe the problem is the parallel access because afaik all nodes relevant to a transaction are locked until it finishes. Can you post your actual Cypher Query? For example this one works for me
MATCH (a:Person {id:x})
MATCH (b:Person {id:y})
MERGE (a)-[r:MET]->(b)
ON MATCH
SET r.count = r.count+1
ON CREATE
SET r.count = 0
05-09-2020 03:56 AM
I don't believe the problem is the parallel access because afaik all nodes relevant to a transaction are locked until it finishes. Can you post your actual Cypher Query? For example this one works for me
MATCH (a:Person {id:x})
MATCH (b:Person {id:y})
MERGE (a)-[r:MET]->(b)
ON MATCH
SET r.count = r.count+1
ON CREATE
SET r.count = 0
05-12-2020 10:39 AM
Yes, you are right.
Initial I thought this is due to the parallel requests received by function, but the main issue was.
I had query
Merge(a)-[r:MET{timeStamp:datetime($timeStamp), count:0}]->(b)
So each request has a different different time stamp and thus it was forming multiple MET relations instead of one.
I replace the query which you have highlighted above and it worked.
All the sessions of the conference are now available online