You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MATCH (u:`user`)-[:watched]->(m:`movie`) WHERE id(u) == "u_100001667"
WITH collect(id(m)) AS watched_movies_id
MATCH (u:`user`)-[e:watched]->(m:`movie`)-[:directed_by|acted_by|with_genre]->(intersection)<-[:directed_by|acted_by|with_genre]-(recomm:`movie`)
WHERE id(u) == "u_100001667" AND NOT id(recomm) IN watched_movies_id
RETURN DISTINCT recomm
返回了7424条结果,而
GO FROM "u_100001667" OVER watched YIELD dst(edge) as watched_movies_id |
GO FROM $-.watched_movies_id OVER * YIELD src(edge) as watched_movies_id,dst(edge) as des |
GO FROM $-.des OVER * REVERSELY WHERE src(edge) != $-.watched_movies_id YIELD DISTINCT src(edge) as recomm
和
MATCH (u:`user`)-[:watched]->(m:`movie`) WHERE id(u) == "u_100001667"
WITH m,collect(id(m)) AS watched_movies_id
MATCH (m:`movie`)-[:directed_by|acted_by|with_genre]->(intersection)<-[:directed_by|acted_by|with_genre]-(recomm:`movie`)
WHERE NOT id(recomm) IN watched_movies_id
RETURN DISTINCT recomm
GO FROM "u_100001667" OVER watched YIELD dst(edge) as watched_movies_id |
GO FROM $-.watched_movies_id OVER * YIELD src(edge) as watched_movies_id,dst(edge) as des |
GROUP BY $-.des YIELD collect($-.watched_movies_id) as watched_movies_id,$-.des as des|
GO FROM $-.des OVER * REVERSELY WHERE NOT src(edge) IN $-.watched_movies_id YIELD DISTINCT src(edge) as recomm
先说两个 MATCH 之间的差异点:WITH m, collect(id(m)) AS watched_movies_id,这句 with 表示的是按照变量 m 做分组,所以这里的 watched_movies_id 也就只有一个电影的 id,第二句 match 表示的只是推荐的电影不能跟当前电影是同一部电影,这个跟第一句的 match 语意不同。
返回了7424条结果,而
和
都返回了7430条结果
我觉得这几条语句应该都是一样的,从user u_100001667 出发,经过6个他看过的电影找到所有和他看过的电影同分类的并且没看过的电影;
我写错了吗,请问他们有啥区别呢
The text was updated successfully, but these errors were encountered: