javascript - Duplicate Nodes created neo4j and nodejs -


I have JSON data through which I am making a connection between nodes and nodes using the connector.

I have followed JSON format

  {att0: "abcd", att1: "val1", att2: "val2", att3: "val3", att4 : "Val4", att5: "val5", att6: "val6", att7: "val7", att8: "val8"} .... This way about 1000 around att0 + att1 i have unique ID Gives UID1) and AT4 gives me unique ID after MD5 hash (give it a UID2). And att7 gives me unique ID after MD5 hash (give it UID3).  

I am creating two nodes of the following properties:

  node 1: {id: UID1, att3: "val3"} node 2: {Id: uid2, at 5: "well 5", at 6: "well 6"} relationship with node 1 - & gt; Node 2: {ID: UID3, AT5: "Well 8"}  

My data entry query is as follows:

 For  (i = 0; i & lt; 1000; i ++) {// 1000 Objects, make Jason / UID1, UID2 and UID3 for each object based on the information above and query_string = merge (n: nodes_type1 {id : 'UID1'}), create the following query string. Set on n = {ID: 'UID1', AT3: 'Well 3'}, NCOU = 1 match set n.count = n.count +1 on (M: node_type2 {ID: 'UID2'}) Set the match on current set M = {id: 'UID2', att5: 'val5', att6: 'val6'}, m.count = 1, m.count = m.count +1 merge ( N) - [x: relation_type {id: 'UID3'}] - & gt; (M) set set x = {AT8: 'well 8', id: 'UID3'}, X season = 1 match x.count = x.count +1 return n db.query (query_string, params , Function (error, result) {if (err) {console.log (err); Onsole.log ("Built node !!! First of all I cleaned my neo4j database using external query while using neo4j database UI I do: The problem now occurs when I return the MATCH query (n: nodes_type2). (N) Since Jason has 1000 objects, it should make 1,000 nodes But the result is more than 1000 (about 9 000) coming and every time it changes, I clear the data and restart the script. As a result, the same UID has more than one node. They match the query handle node Merge counters should be increased but after a few numbers, the same UID is created with the same node.   

I understand that Your questions are executed extensively in parallel, ensure a unique obligation for

: nodes_type1 (id) and nodes_type2 (id) Installed, otherwise the merge can not guarantee specificity.

Apart from this, you should change your query to use parameters I nstead of literal values ​​

and should also look like this:

> MERGE (n: nodes_type1 {id: {id1}} n set .att3 = {att3}, n.count = 1 match sets n.count = n.count +1 merge (M: nodes_type2 {id: {id2}}) set to m.att5 = {att5}, m. att6 = {att6}, m.count = 1 matches m.count = m.count merge merge (N) - [x: relation_type {id: {id3}}] - & gt; (m) set set x.att8 = {att8}, x.count = 1 match set x.count = x.count + 1 return n, r, m

I do not want to The user ID and is prudent in actual use-case to counter a relationship, but it may be right for your test


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -