按日期使用 NEXT 复制连接节点

connect nodes with NEXT replation by date

我有这个示例图:

http://console.neo4j.org/?id=mginka

我正在尝试找到一个 Cypher 代码,它将通过具有 [NEXT] 关系的 date_time 字段连接每个会话的所有命中节点 – 来自不同会话的点击不应连接..

谢谢, 里尔

根据您的控制台图,此查询可以解决问题:

MATCH (session:Session)
MATCH (session)<-[:IN_SESSION]-(hit)
WITH session, hit
ORDER BY hit.date_time ASC 
WITH session, collect(hit) AS hits 
UNWIND range(1, size(hits)-1) AS hitKey
MATCH (prev) WHERE id(prev) = id(hits[hitKey-1])
MATCH (current) WHERE id(current) = id(hits[hitKey])
MERGE (prev)-[:NEXT]->(current)