Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queries with the same semantics return different results #5418

Closed
Dong148 opened this issue Mar 20, 2023 · 3 comments
Closed

Queries with the same semantics return different results #5418

Dong148 opened this issue Mar 20, 2023 · 3 comments
Labels
type/question Type: question about the product

Comments

@Dong148
Copy link

Dong148 commented Mar 20, 2023

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

都返回了7430条结果

我觉得这几条语句应该都是一样的,从user u_100001667 出发,经过6个他看过的电影找到所有和他看过的电影同分类的并且没看过的电影;
我写错了吗,请问他们有啥区别呢

@Sophie-Xie Sophie-Xie changed the title 我觉得语义相同的查询语句返回了不同的结果 Queries with the same semantics return different results Mar 20, 2023
@Dong148
Copy link
Author

Dong148 commented Mar 22, 2023

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

似乎原来的语句里面WHERE没有发挥作用,这样改写之后返回的结果是7424

@Sophie-Xie Sophie-Xie added the type/question Type: question about the product label Mar 27, 2023
@yixinglu
Copy link
Contributor

先说两个 MATCH 之间的差异点:WITH m, collect(id(m)) AS watched_movies_id,这句 with 表示的是按照变量 m 做分组,所以这里的 watched_movies_id 也就只有一个电影的 id,第二句 match 表示的只是推荐的电影不能跟当前电影是同一部电影,这个跟第一句的 match 语意不同。

同样两句 GO 差不多也是上述的差异

@QingZ11
Copy link
Contributor

QingZ11 commented May 5, 2023

@Dong148 这个 issue 超过一个月没有更新内容了,这边先行关闭了。如果你有任何更新的内容,可以再打开这个 issue。

谢谢你的反馈 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question Type: question about the product
Projects
None yet
Development

No branches or pull requests

4 participants