I could use some advice on how to do a specific search. I apologise if this is a ridiculous easy thing to bother you with.
Given a database with 2 different node types, Company and PSC, where Company has a one to many relationship with PSC nodes :IS_PSC_OF. I need to match all companies whose related PSCs don't come from the UK.
I can't grasp in my inexperienced Cypher abilities how to do this.
If I were coding this it would look something like this, but boy does it not like it and I'm struggling to think of an alternative after scouring the documentation.
// Find all Companies
MATCH (c:Company)
// Loop over each 'c' counting related PSC nodes that are in the UK and set result as property on company
FOREACH (comp IN nodes(c) | SET comp.NumberUKPeople = count(MATCH (comp)-[:IS_PSC_OF]-(p) WHERE NOT p.country <> "UK"))
Then in a separate query I could get the results by simply searching for
MATCH (c:Company)
WHERE c.NumberUKPeople = 0
RETURN c
Am I over complicating this?
How can I aggregate all Companies whose related PSC's country property do not match a certain value and return all these companies?
Many thanks