【问题标题】:How to use cypher to create relationship between two nodes given their attributes in Neo4j给定 Neo4j 中的属性,如何使用 cypher 在两个节点之间创建关系
【发布时间】:2013-05-07 03:07:21
【问题描述】:

我想做这样的事情

START n=node(*), m=node(*)  where has(n.userid) and has(m.userid) and n.userid='0' and m.userid='3'  create (n)-[FRIENDSHIP {status:2}]->(m) ;

但是,Neo4j 不喜欢 where 子句。最好的方法是什么?

非常感谢!

【问题讨论】:

    标签: database neo4j cypher graph-databases


    【解决方案1】:

    你得到什么错误表明 Neo4j 不喜欢 where 子句?

    我跑了

    START n=node(*), m=node(*)  
    where has(n.name) and has(m.name) and n.name='Neo'
    create (n)-[:FRIENDSHIP {status:2}]->(m)
    

    在console.neo4j.org 上运行良好。 请注意,您错过了关系名称之前的 :。这是它抱怨的错误吗?

    如果这仍然不起作用,您使用什么版本?

    【讨论】:

    • 嗨 Luanne,非常感谢您的回复!我类似地尝试了 START n=node(), m=node() where has(n.userid) and has(m.userid) and n.userid='2' and n.userid=' 3' 创建 (n)-[:FRIENDSHIP {status:2}]->(m) ;它不报告错误。但是,Neoclipse 不会在可视化中显示边缘。
    • 我在node()中有*,粘贴后就丢失了
    • 这是 Cypher 1.0。在 2.0 中使用 MATCH 语句而不是 START。这是由于向更具声明性的语言结构发展,即告诉机器你想要什么,而不是你想要什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多