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.

How to select One hop relationship nodes with some conditioning filter

Hello,
I am newbie in neo4j. I want to select one hop distance nodes with some conditions2X_a_a6d91b86d8f1192abfb8cb620a19363ea49f6444.png

so Here Node A has two adjacent nodes B and C . and C here connected with D by relationship Pay
I will take only B here cause. I will select those node which don't have 'pay' relationship with other nodes.

so far I have done this

Match (c:ID:'064'})-[r:SEND | AIRS]->(d) return distinct(d).ID as RecieverID

so it gives me one hop distance neighbour those have 'send' and 'air' relationship. but some of this neighbour nodes has pay relationship with other nodes. I don't want to include this nodes .My desire out put is to obtain those adjacent neighbour which don't have 'Pays' relationship with other nodes
How could I solve this. any guidance and approaches are highly appreciated

1 REPLY 1

To exclude a pattern that must not exist you have to use WHERE NOT:

Match (c:ID:'064'})-[r:SEND | AIRS]->(d) 
WHERE NOT (d)-[:PAYS]->()
return distinct(d).ID as RecieverID
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online