neo4j - 如何创建独特的关系 neo4j 2.0

标签 neo4j cypher

我正在尝试在 neo4j 中的实体之间创建一些独特的关系。现在我有作者和文章,它们之间有 Authored 关系。我想在实体之间创建 CoAuthored 关系

像这样

match (a)-[r]->(b)<-[r2]-(c)
create (a)-[new:CoAuthor]->(c)

但是,我想创建一个独特的共同作者关系,但如果它已经存在则更新权重。我看到了这个 postm 但不再支持语法 In Cypher, how can I create a relationship if it doesn't exist; update property if it does
SyntaxException: This syntax is no longer supported (missing properties are now returned as null). Please use (not(has(<ident>.weight)) OR <ident>.weight=<value>) if you really need the old behavior.

我不太明白我要替换的是什么。我查看了 Merge 命令,但无法使其正常工作

最佳答案

您应该可以替换 createmerge在这种特殊情况下。

match (a)-[r]->(b)<-[r2]-(c)
merge (a)-[new:CoAuthor]->(c)
on create set new.weight=1
on match set new.weight=new.weight+1

关于neo4j - 如何创建独特的关系 neo4j 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20944812/

相关文章:

neo4j - Janusgraph 功能和 future

Neo4j http.log 为空

mongodb - 将 mongodb 与 neo4j 集成,是否有任何 API 可以链接它们?

neo4j - 密码查询 : Is it possible to "hide" an existing path with a "virtual relationship"?

csv - 如何将包含 boolean 值的 CSV 导入 Neo4j

css - Neo4j 2.0.1 graphstyle.grass 用于多个标签

r - 将neo4j与R一起使用

python - 将数据从 neo4j 导出到 csv 而不是 json

neo4j - 如何使用 Cypher/Neo4J 获取所有节点或给定标签的所有属性键?

elasticsearch - 图辅助搜索结果过滤示例