Reputation: 33
I write a Cypher statment:
match p=(:Fabric)-[:Child*]-(f:Fabric{code:'PC16-18121'})-[:Child*]-(ef:Fabric)
match (ef)-[:Refrence]-(r:RequestOrder)
return p,r
Result: image
But I want another result: Don't display the node that without ‘result’ relationship
Question:
How to write this in Cypher?
Upvotes: 2
Views: 677
Reputation: 33
With the help of InverseFalcon's example I know what to do:
match (f:Fabric{code:'PC16-18121'}),
(f)-[:Child*]->(:Fabric)-[:Refrence]-(r:RequestOrder)
where not (r)-[:Result]-()
return (f)-[:Child*]->(:Fabric),(:Fabric)-[:Child*]->(f),
(f)-[:Child*]->(:Fabric)-[:Refrence]-(r:RequestOrder)
Result is: Result Image
Thank you @InverseFalcon
Upvotes: 1
Reputation: 30397
You can add a pattern predicate to indicate you only want :RequestOrders without :Result relationships.
Also, we can clean up that query a bit, currently it's matching down :Child* relationships to :Fabrics twice.
match p=(:Fabric{code:'PC16-18121'})-[:Child*]-(:Fabric)-[:Refrence]-(r:RequestOrder)
where not (r)-[:Result]-()
return p,r
You may also want to correct the spelling of :Reference in your graph.
EDIT: to get the path to all :FABRIC nodes as well, try this:
match p=(:Fabric{code:'PC16-18121'})-[:Child*]-(f:Fabric)
optional match (f)-[:Refrence]-(r:RequestOrder)
where not (r)-[:Result]-()
return p,r
Upvotes: 1