Newest posts of your friends

Return the newest 20 posts liked by the friends of a user during a time interval.

T-Cypher:

RANGE_SLICE [2010-01-01T08:00:00Z; 2013-01-01T08:00:00Z]

MATCH (p1:Person)-[k:Knows]->(p2:Person),

(p2)-[l:likes]->(p:Post)

WHERE k@T BEFORE l@T AND p1.ID = ‘X’

RETURN p ORDER BY START(p@T) DESC LIMIT 20


Interpretation:

This query returns the most recent posts liked by the friends of a user during a time interval. In the above query, the returned results are sorted by the decreasing chronological order of the posts, then  limited to most recent 20 posts.


Cypher query:

MATCH (p1:`Person`)-[k:`Knows`]->(p2:`Person`), (p2)-[l:`likes`]->(p:`Post`)

WHERE (p1.ID = ‘X’ AND k.tEnd < l.tStart AND ((myFunctions.min([p1.tEnd, 1357027200000]) – myFunctions.max([p1.tStart, 1262332800000])) > 0 OR (myFunctions.min([p2.tEnd, 1357027200000]) – myFunctions.max([p2.tStart, 1262332800000])) > 0 OR (myFunctions.min([p2.tEnd, 1357027200000]) – myFunctions.max([p2.tStart, 1262332800000])) > 0 OR (myFunctions.min([p.tEnd, 1357027200000]) – myFunctions.max([p.tStart, 1262332800000])) > 0 OR (myFunctions.min([k.tEnd, 1357027200000]) – myFunctions.max([k.tStart, 1262332800000])) > 0 OR (myFunctions.min([l.tEnd, 1357027200000]) – myFunctions.max([l.tStart, 1262332800000])) > 0))

RETURN p ORDER BY myFunctions.start([p.tStart, p.tEnd]) DESC LIMIT 20

Comments are closed.