Reputation: 803
I've to write one cypher for schema where all nodes are having multiple relations in between them. So I want to filter the nodes lets say, first search nodes which have relation HELPSin between theme. Then on Check if those nodes also have KNOWSrelation in between them then return all nodes with all other relations(including HELPS & KNOWS). Right now to filter the relation I'm using below cypher:
MATCH (a)-[r:HELPS]->(b)
WITH distinct a,b
MATCH (a)-[rs:KNOWS]-(b)
RETURN a,b LIMIT 25
MATCH (a)-[r:HELPS AND KNOWS]->(b)
WITH DISTINCT a,b
path = (a)-[*]-(b) //To get all other relations in between filtered nodes.
RETURN rels(path),nodes(path)
Thanks.
Upvotes: 0
Views: 454
Reputation: 15490
i don't think there is any AND operation for this type of query
you can use
MATCH (a)-[:HELPS]->(b)-[:KNOWS]-(a)
WITH DISTINCT a , b
MATCH a-[r]-b
WHERE NOT type(r) IN ['HELPS', 'KNOWS']
RETURN r
Upvotes: 2
Reputation: 2583
The below will get all other relations between a and b , apart from helps
and knows
.
MATCH p = (b)<-[KNOWS]-(a)-[HELPS]->(b)
WITH a,b
MATCH a-[r]->b
WHERE NOT type(r) IN ['HELPS', 'KNOWS']
RETURN r
Upvotes: 2