简体   繁体   English

neo4j密码查询说明结果

[英]neo4j Cypher Query Explain result

Im trying to find 'friend of friend' level recommendation in the given neo4j test data set, and I have come up with these two queries and Im not able to identify the bug in second query as it contains one extra node - '8' (Emil Eifrem). 我试图在给定的neo4j测试数据集中找到“朋友的朋友”级别的推荐,但我提出了这两个查询,由于第二个查询包含一个额外的节点-'8'(埃米尔·埃弗雷姆(Emil Eifrem)。 Please help me understand the difference. 请帮助我了解区别。 Thanks 谢谢

1) 1)

MATCH (keanu:Person {name:"Keanu Reeves"})-[:ACTED_IN]->()<-[:ACTED_IN]-(f),
    (f)-[:ACTED_IN]->()<-[:ACTED_IN]-(fof) 
WHERE NOT (keanu)-[:ACTED_IN]->()<-[:ACTED_IN]-(fof) AND fof <> keanu 
RETURN fof;

vs VS

2) 2)

MATCH (keanu:Person {name:"Keanu Reeves"})-[:ACTED_IN]->(movie)<-[:ACTED_IN]-(f),
    (f)-[:ACTED_IN]->(f_movies)<-[:ACTED_IN]-(fof) 
WHERE NOT (movie)<-[:ACTED_IN]-(fof) AND fof <> keanu
RETURN fof;

The movie you are referring to in the second WHERE clause is one concrete movie that was matched in the MATCH clause before, so you only check against that single movie and not all potential movies between the fof and Keanu Reeves. 您在第二个WHERE子句中引用的电影是之前在MATCH子句中匹配的一部具体电影,因此,您只检查该单个电影,而不检查fof和Keanu Reeves之间的所有潜在电影。 That's why you filter out fewer people. 这就是为什么您过滤掉更少的人的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM