【发布时间】:2015-10-15 06:53:19
【问题描述】:
到目前为止,我已经尝试过此查询,但扫描所有节点时速度确实很慢。它能够实现我想要检索的内容
match (u:Users{user_id:140}),(p:Posts),(pu:Users{user_id:p.created_by}) optional match (p)-[:POST_MEDIA]->(f) optional match (p)-[:COMMENT]->(c)<-[:COMMENT]-(u3)
where
(p)-[:CREATED_BY]->(u) or (p:PUBLIC and (u)-[:FOLLOW]->(pu) )or (p:PRIVATE and (p)-[:SHARED_WITH]->(u))
return {user_id:pu.user_id,firstname:pu.firstname,lastname:pu.lastname,profile_photo:pu.profile_photo,username:pu.username} as pu,p,collect({user_id:u3.user_id,profile_photo:u3.profile_photo,text:c.text}) as comment,collect(f) as file order by p.post_id DESC limit 25
在此查询之前,我尝试了此查询,该查询速度非常快,但无法检索完整的新闻提要正在检索新闻源。
match (u:Users{user_id:140})-[:FOLLOW]->(pu)<-[:CREATED_BY]-(p:Posts)
optional match (p)-[:POST_MEDIA]->(f)
optional match (p)-[:COMMENT]->(c)<-[:COMMENT]-(u3) where p:PUBLIC
return
{user_id:pu.user_id,firstname:pu.firstname,
lastname:pu.lastname,profile_photo:pu.profile_photo,username:pu.username} as pu,p,
collect({user_id:u3.user_id,profile_photo:u3.profile_photo,text:c.text}) as comment,
collect(f) as file order by p.post_id DESC limit 25
注意:- 在 where 子句中不要像这样修改:-
where p:PUBLIC or (p)-[:SHARED_WITH]->(u)
// but the only problem is that how i should include posts of users himself which is retrieving news feed .
【问题讨论】: