cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to serch using "for all" condition?

I'm developing an article recommendation system. When a user read article1, article2, ..., and articlen, the system recommend next articles.

I want to do something like the following:

MATCH (a:Article)
WHERE {for all x such that (x:Article)-[:next]->(a:Article), x.read=true}
RETURN a

How do I write this?

2 REPLIES 2

intouch_vivek
Graph Steward

Hi Kobayashi,

You can use Optional Match

match(a:Article)
optional match (x:Article)-[:next]->(a:Article) set x.read=TRUE return x

ameyasoft
Graph Maven

This query is going to set read = true flag for all users. You need to select the articles read by a user and set the flag to true for that user.