neo4j用collect 代替union 并实行分页

MATCH pa=(j:User)-[r:PostLikeRel|:ReplyRel|:RetweetRel]->(m:User{guid:"f092a1dc6c23b26b020bda24b9e8c923"}) 
where (j.acc is not null and j.acc <> '' and j<>m)
with collect({acc:j.acc, guid:j.guid, pcnt:coalesce(r.pcnt,0), lcnt:coalesce(r.lcnt,0), type:type(r)} ) as rows1

OPTIONAL MATCH po=(j:User)<-[r:PostLikeRel|:ReplyRel|:RetweetRel]-(m:User{guid:"f092a1dc6c23b26b020bda24b9e8c923"}) 
where (j.acc is not null and j.acc <> '' and j<>m) 
with rows1+ collect({acc:j.acc, guid:j.guid, pcnt:coalesce(r.pcnt,0), lcnt:coalesce(r.lcnt,0), type:type(r)+"_"}) as allrows

unwind allrows as row
with row.acc as acc, row.guid as guid, row.pcnt+row.lcnt as pcnt, row.type as type
return acc,guid, pcnt,type
order by pcnt desc
skip 0 limit 20

  

原文地址:https://www.cnblogs.com/learningJAVA/p/10245805.html