abhaygarg12493
abhaygarg12493

Reputation: 1605

How to filters data at node level in Neo4j Cypher

Let suppose we have two match and now we want something like that (match1-match2)

match (u:User)-[r:HAS_RESOURCES]-(resource:Resource) where id(u)=1484
 match (resource1:Resource)-[r1:OWNED_BY_USER]-(owner:User) where resource1.isPublished=true return resource1

This cypher we made . So now we want something like this id(resource1)-id(resource)

Upvotes: 0

Views: 100

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41676

you can filter resources that are not in a collection.

Make sure to have an index on :Resource(isPublished) otherwise you have to scan across all resources.

match (u:User)-[r:HAS_RESOURCES]-(resource:Resource) where id(u)=1484
with collect(resource) as resources
match (resource1:Resource) 
where resource1.isPublished=true and NOT (resource1 IN resources)
return resource1

Upvotes: 1

Related Questions