cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Count no of relation between first level and second level contact

Hi, I have to count number of MET_EVENT between personId= 1222333442 and 1222333441 , between personId =1222333441 and personId = 1222333445.

I am running this query -

   match (p:Person) where p.nationalId = "1222333442"
    match (p:Person)-[r1:MET_EVENT]->(other:Person)-[r2:MET_EVENT]->(a:Person)
    where NOT (p)-[:MET_EVENT]->(a) and not p.nationalId=a.nationalId
    return         
    distinct(a.nationalId) as secondLevelContact,
    count(r2) as secondLevelContactCount,      
     other.nationalId as firstLevelContact,
     count(r1) as firstLevelContactCount,
     p.nationalId as nationalId 

But i am getting this result -

Exclude row 1 and row3
For row number 2, firstLevelContactCount is 3 which is correct but secondLevelContactCount should be 1 instead of 3.

What could be the issue?

1 REPLY 1

intouch_vivek
Graph Steward

Hi,

Count is coming 3 from
1222333441 --> 1222333442 ====2
1222333441 --> 1222333445 ====1

First scenario is coming in picture because no condition applied on other.
(other:Person)-[r2:MET_EVENT]->(p:Person) is also coming in consideration