【问题标题】:Find the actors who DID NOT act with Hugo Weaving but acted with his co-stars, and SET a property act with value as didnot on those actors找到没有与 Hugo Weaving 一起演戏但与他的合作演员一起演戏的演员,并在这些演员身上设置一个没有价值的财产行为
【发布时间】:2020-05-02 07:10:44
【问题描述】:

我想找到没有与 Hugo Weaving 一起演戏但与他的合作演员一起演戏的演员,并为这些演员设置一个没有价值的财产行为。

到目前为止我所做的是:

Match (p: Person), (other: Person), (m: Movie)
where (NOT (:Person {name:'Hugo Weaving'})-[:ACTED_IN]->(m)<-[:ACTED_IN]-(p)) 
AND  (p)- [:ACTED_IN]->(m)<-[:ACTED_IN]-(other)
set other.act = 'didnot'
return distinct other

这给了我结果(前 5 行)。:

╒══════════════════════════════╕
│"other"                       │
╞══════════════════════════════╡
│{"act":"didnot","born":1964,"n│
│ame":"Keanu Reeves"}          │
├──────────────────────────────┤
│{"act":"didnot","born":1967,"n│
│ame":"Carrie-Anne Moss"}      │
├──────────────────────────────┤
│{"act":"didnot","born":1961,"n│
│ame":"Laurence Fishburne"}    │
├──────────────────────────────┤
│{"act":"didnot","born":1978,"n│
│ame":"Emil Eifrem"}           │
├──────────────────────────────┤
│{"act":"didnot","born":1975,"n│
│ame":"Charlize Theron"}       │

结果不正确,而且查询看起来效率低下。我究竟做错了什么? 任何对正确方向的见解都将受到高度赞赏。谢谢。

【问题讨论】:

    标签: neo4j cypher


    【解决方案1】:

    你能试试下面的代码吗,它给了我 48 个这样的演员。

    MATCH(hw:Person{name:"Hugo Weaving"})-[:ACTED_IN]->(m:Movie)<-[:ACTED_IN]-(co:Person)
    WITH hw, co
    MATCH (co)-[:ACTED_IN]->(m2:Movie)<-[:ACTED_IN]-(co2:Person)
    WHERE co2.name <> "Hugo Weaving"
    AND NOT (co2)-[:ACTED_IN]->(:Movie)<-[:ACTED_IN]-(hw)
    RETURN DISTINCT co2.name
    

    其中很少有:

    "David Morse"
    "Sam Rockwell"
    "Gary Sinise"
    "James Cromwell"
    "Bonnie Hunt"
    "Patricia Clarkson"
    "Michael Clarke Duncan"
    ....
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-20
      • 1970-01-01
      • 2015-05-19
      • 2013-05-19
      • 2020-04-11
      • 1970-01-01
      • 2014-01-20
      • 1970-01-01
      相关资源
      最近更新 更多