I have these nodes:
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
And these relationships:
(user) - [: FOLLOWED] -> (tag)
// the user follows the tag (thread) - [: BELONG_TO] -> (tag)
// the post belongs to tag (user) - [: READ] -> (thread)
// user reads the post Now I want to query 5 posts belong to tag user follow user has not read that thread, and that thread must be up to date, order by point DESC. I created index on User(user_id), Tag(tag_id), Thread(thread_id) and i run this cypher query from the browser:
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
With just 1 node in database (also embedded ) took 235 ms. Obviously something is going wrong. What could be the problem. Pleace hepl me
In your MATCH you have a bi-directional pattern.
(t:Tag)<-[:BELONG_TO]->(th)
Do you have set an index or constraint on :User(user_id) ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.