Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j 在整个数据库上运行Cypher查询_Neo4j_Cypher - Fatal编程技术网

Neo4j 在整个数据库上运行Cypher查询

Neo4j 在整个数据库上运行Cypher查询,neo4j,cypher,Neo4j,Cypher,我有一组两种类型的实体,Author和Reference,它们通过“Authored”类型从->R连接。有人帮我想出了这个代码来添加一组新的关系 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 匹配(a)-[r]->(b)(c) 在创建时设置新的。权重=1 在匹配集上新建。权重=新

我有一组两种类型的实体,Author和Reference,它们通过“Authored”类型从->R连接。有人帮我想出了这个代码来添加一组新的关系

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
匹配(a)-[r]->(b)(c)
在创建时设置新的。权重=1
在匹配集上新建。权重=新建。权重+1
但是,我的内存一直不足。我尝试使用以下代码限制此操作的执行次数:

start a=node(1)
match (a)-[r:Authored]->(b)<-[r2:Authored]-(c)
with a
limit 10
match (b)<-[r2]-(c)
create (a)-[new:CoAuthor]->(c);
start a=节点(1)
匹配(a)-[r:Authored]->(b)尝试此选项(继续运行,直到从计数中返回0;如果1000足够快,可能尝试增加到10000):


match(a)-[r:Authored]->(b)第一个想法是可行的,尽管有点劳动密集。我本不想尝试插入一个无方向的边缘;相反,我希望找到一个适当的解决方案,然后插入一个方向相反的边标题。我会让你知道第二个解决方案是否有效。tyvm如果您希望它是定向的,您希望每对作者有两条边吗?不特别是因为它通常不被认为是定向关系。然而,我想我已经读到Neo4j处理定向关系更有效。Neo4j总是以定向的方式存储关系,但是如果您创建了没有方向的unique,它将只创建一个关系(因为它匹配任一方向),而不是两个。好的。如果没有id属性,是否有方法选择前x个节点?
match (a)-[r:Authored]->(b)<-[r2:Authored]-(c)
where NOT (a)-[:CoAuthor]-(c)
with a, c
limit 1000
create unique (a)-[new:CoAuthor]-(c)
return count(*)
match (a)-[r:CoAuthor]-(b)
with length((a)-[:Authored]->()<-[:Authored]-(b)) as count, r
set r.weight=count