问题描述
我拥有的图形架构为(actors)-[:ACTED_IN]->(movies)
.
我知道如何找到与特定演员合作过的演员,如下所示:
I know how to find actors who have worked with a particular actor as below:
MATCH (actor {name:"Tom Hanks"} )-[:ACTED_IN]->(movies)<-[:ACTED_IN]-(costars)return distinct costars;
MATCH (actor {name:"Tom Hanks"} )-[:ACTED_IN]->(movies)<-[:ACTED_IN]-(costars)return distinct costars;
我知道如何找到在某部电影中工作过的所有演员:MATCH (all_actor)-[:ACTED_IN]->(movies) return distinct all_actor;
I know how to find all the actors who have worked in some movie:MATCH (all_actor)-[:ACTED_IN]->(movies) return distinct all_actor;
但是,我不知道如何找到所有不在Costars中的演员.我该怎么办?
However I don't know how to find all actors not in costars. How do I go about it?
推荐答案
要从角色的全局列表中扣除角色时,这不是最佳的图形查询,这里有一些建议.
As you want to deduct the coactors from the global list of actors this is not the best graph query, here are some suggestions.
// Max de Marzi
MATCH (actor:Actor {name:"Tom Hanks"})-[:ACTED_IN]->(movie), (other:Actor)
WHERE NOT (movie)<-[:ACTED_IN]-(other)
RETURN other
// Wes Freeman
MATCH (actor:Actor {name:"Tom Hanks"}), (other:Actor)
WHERE NOT (actor)-[:ACTED_IN]->()<-[:ACTED_IN]-(other)
RETURN other
// Michael Hunger
MATCH (actor:Actor {name:"Tom Hanks"} )-[:ACTED_IN]->(movies)<-[:ACTED_IN]-(coactor)
WITH collect(distinct coactor) as coactors
MATCH (actor:Actor)
WHERE NOT actor IN coactors
RETURN actor
这篇关于Neo4j-不在查询中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!