Alvaro
Alvaro

Reputation: 1448

Match relationships if a certain parameter exists

I've been using neo4j for a while and recently i got stuck with a query that i don't seem to be able to succesfully run.

My goal: I have a type of relationship called HAS_RELATIONSHIP. this type of rel sometimes hasa property called verified. I want to get a subgraph of those relationships that don't have this property so i can afterwards add the property.

What I have done so far:

Match (a)-[r:HAS_RELATIONSHIP]-(b) 
where  r.verified=False 
set r.verified=True
LIMIT 5
return r, a, b

the part that is not working is where r.verified=False it should be something like exists(r)=verified but t doesn't seem to exist this kind of query. I have checked on OPTIONAL MATCH, but it seems it is neither the solution.

Any ideas?

Upvotes: 1

Views: 82

Answers (1)

hedengran
hedengran

Reputation: 63

You can use the NOT operator together with the predicate function exists() for this problem:

MATCH (r) WHERE NOT exists(r.verified) RETURN r

Upvotes: 1

Related Questions