我有这些节点:
user{user_id}: users
thread{thread_id, published_date, like_count, comment_count, view_count}: posts
tag_id{tag_id}: the tag of the post
这些关系:
(user) - [: FOLLOWED] -> (tag)
//用户关注标签(thread) - [: BELONG_TO] -> (tag)
//帖子属于标签(user) - [: READ] -> (thread)
//用户阅读帖子现在我要查询5个属于标签用户的帖子,关注者用户尚未阅读该线程,并且该线程必须是最新的,并按DESC顺序排序。我在User(user_id),Tag(tag_id),Thread(thread_id)上创建了索引,并从浏览器运行了以下密码查询:
MATCH (u:User)-[:FOLLOWED]->(t:Tag)<-[:BELONG_TO]-(th)
WHERE u.user_id = 3 AND NOT EXISTS((u)-[:READ]->(th))
WITH u.user_id AS user_id, th.thread_id AS thread_id,
t.tag_id AS tag_id,duration.inDays(datetime(),
datetime(th.published_date)).days AS days,
(0.5*th.like_count + 0.3*th.comment_count + 0.2*th.view_count) AS point
ORDER BY days DESC
RETURN DISTINCT thread_id SKIP 0 LIMIT 5
在数据库中只有1个节点(也已嵌入)花费了235毫秒。显然出了点问题。可能是什么问题呢。请让我高兴
答案 0 :(得分:0)
在您的MATCH中,您有一个双向模式。
(t:Tag)<-[:BELONG_TO]->(th)
您是否对:User(user_id)设置了索引或约束?