// First Applicant
MERGE (applicant_a:Applicant{firstName:'JOSE', lastName:'JONES'})
MERGE (phone1_a:Phone{number:'5555555555'})
MERGE (phone1_a)<-[:HAS_PHONE]-(applicant_a)
MERGE (phone2_a:Phone{number:'2222222222'})
MERGE (phone2_a)<-[:HAS_PHONE]-(applicant_a)
MERGE (ipAddress_a:IpAddress{ip:'204.192.128.33'})
MERGE (ipAddress_a)<-[:HAS_IP]-(applicant_a)
MERGE (bankAccount_a:BankAccount{routing:'12345678',account:'456789'})
MERGE (bankAccount_a)<-[:HAS_ACCOUNT]-(applicant_a)
// Second Applicant
MERGE (applicant_b:Applicant{firstName:'BRIAN', lastName:'CRAST'})
MERGE (phone1_b:Phone{number:'4444444444'})
MERGE (phone1_b)<-[:HAS_PHONE]-(applicant_b)
MERGE (phone2_b:Phone{number:'9999999999'})
MERGE (phone2_b)<-[:HAS_PHONE]-(applicant_b)
MERGE (ipAddress_b:IpAddress{ip:'127.0.0.1'})
MERGE (ipAddress_b)<-[:HAS_IP]-(applicant_b)
MERGE (bankAccount_b:BankAccount{routing:'9876543',account:'123456'})
MERGE (bankAccount_b)<-[:HAS_ACCOUNT]-(applicant_b)
// Third Applicant
MERGE (applicant_c:Applicant{firstName:'STEVE', lastName:'DUNPHY'})
MERGE (phone1_c:Phone{number:'2222222222'})
MERGE (phone1_c)<-[:HAS_PHONE]-(applicant_c)
MERGE (phone2_c:Phone{number:'6666666666'})
MERGE (phone2_c)<-[:HAS_PHONE]-(applicant_c)
MERGE (ipAddress_c:IpAddress{ip:'204.192.128.33'})
MERGE (ipAddress_c)<-[:HAS_IP]-(applicant_c)
MERGE (bankAccount_c:BankAccount{routing:'3333333',account:'123454'})
MERGE (bankAccount_c)<-[:HAS_ACCOUNT]-(applicant_c)
// Fourth Applicant
MERGE (applicant_d:Applicant{firstName:'NIKKI', lastName:'COX'})
MERGE (phone1_d:Phone{number:'3333333333'})
MERGE (phone1_d)<-[:HAS_PHONE]-(applicant_d)
MERGE (phone2_d:Phone{number:'7777777777'})
MERGE (phone2_d)<-[:HAS_PHONE]-(applicant_d)
MERGE (ipAddress_d:IpAddress{ip:'202.185.123.11'})
MERGE (ipAddress_d)<-[:HAS_IP]-(applicant_d)
MERGE (bankAccount_d:BankAccount{routing:'12345678',account:'456789'})
MERGE (bankAccount_d)<-[:HAS_ACCOUNT]-(applicant_d)
Trying to find all Applicant nodes that have 1 or more of Phone, IpAddress or BankAccount in common
MATCH (applicant:Applicant)-[r]->(subelement)<-[r2]-(other:Applicant)
WITH applicant, other, collect(subelement) AS overlap
WHERE id(applicant) > id(other) AND size(overlap) > 0
RETURN applicant, other, overlap
Trying to find all Applicant nodes that have 2 or more of Phone, IpAddress or BankAccount in common
MATCH (applicant:Applicant)-[r]->(subelement)<-[r2]-(other:Applicant)
WITH applicant, other, collect(subelement) AS overlap
WHERE id(applicant) > id(other) AND size(overlap) > 1
RETURN applicant, other, overlap