Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-11-2020 10:38 PM
I'm having a customers data base with mobile numbers
each customer mobile number to number has called connection(They have called each other)
the relation of the customer data base can be seen and taken from the call log data base (Which customer has called to another customer a_number HAS CALLED b_number)
so i imported the call log data base assining to customer data base numbers
code:
load csv with headers from 'file:///calldeta.csv' as line
MERGE (n:Customer{mob:line.a_number})-[:CALLED{duration:line.duration}]->(m:Customer{mob:line.b_number})
the problem is it creates multiple lables which duplicates the same number example if
071111 CALLED 07222 then the 2 labels will be created
but if 07111 CALLED 07333 the it creates again a 07111 lable & joins to 07333
I want to make a join from the earlier relaion 07111 CALLED 07222 without make another 07111 label again I want to join from the created 0711 label to 07333
So i can see that 07111 & 07222 & 077333 all have a common connection
03-12-2020 12:06 AM
Hi, MERGE is looking for that entire pattern. As it did not find the entire pattern, the whole pattern is created and that's why you get duplicate nodes.
I suggest read:
For your query, try:
load csv with headers from 'file:///calldeta.csv' as line
MERGE (n:Customer{mob:line.a_number})
MERGE (m:Customer{mob:line.b_number})
MERGE (n)-[:CALLED{duration:line.duration}]->(m)
03-12-2020 08:43 AM
Sir after implementing your code it appeared like this
03-12-2020 07:17 PM
Check your data and look for any comma in any column values. If you can post some sam please data that would be helpful.
03-12-2020 08:30 AM
Hi,
If you are loading the nodes then try the method provided by @paul.are.
However if you already have node placed in the system and want to merge them then try
MATCH (m:Customer)
WITH m.mob as mob, collect(m) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node;
All the sessions of the conference are now available online