I have these nodes:
user{user_id}: usersthread{thread_id, post_date} : poststag_id{tag_id}: the tag of the post
And these relationships:
(user) - [: FOLLOWED] -> (tag)// the user follows the tag(thread) - [: BELONG_TO] -> (tag)// the post belongs to tag(user) - [: READ] -> (thread)// user reads the post
Now I want to query for each tag that user follows 5 posts that user has not read. I wrote cypher as follows:
MATCH (u:User)-[:FOLLOWED]->(t:Tag)
WHERE u.id = 39792
WITH collect(t) as tLists
UNWIND tLists as t
MERGE (u:User)-[:FOLLOWED]->(t:Tag)<-[:BELONG_TO]-(th:Thread)<-[r:READ]-()
WHERE not (u)-[:READ]->(th)
RETURN u.id, th.id, t.id, duration.inDays(datetime(), datetime({ epochmillis: apoc.date.parse(th.post_date)})).days as time, count(r) as count_view
ORDER BY time DESC, count_view DESC
LIMIT 5
But it doesn't work. Help me