1.删除带有关系的节点
a、先删除关系 match (n:Node)-[r:关系名称]-() where (n...条件) delete r
b、删除节点 match (n:Node) where (n...条件) delete n
2.批量更新
:param batch:[{prop1:'property1',prop2:'property2'},{prop1:'property11',prop2:'property22'}]
UNWIND $batch as data MATCH (c:Label1)-[r:关系]->(d:Label2) where c.prop1= data.prop1 and d.prop2=data.prop2 set r.prop= data.prop
3.更新关系名称
.apoc
match (c:DictProduct)-[r:原关系]-(d:DictProduct) with r
call apoc.refactor.setType(r, '新关系') yield input,output return *
4.导出数据
./neo4j-admin dump --database=kg.db --to=../
5.导入数据(dump文件)
./neo4j-admin load --from=./graph.db.dump --database=neo4j.db --force=true
导入数据(csv文件)
using periodic commit 1000 load csv from "http://127.0.0.1:8080/data.csv" as row CREATE (:Node{id:toInt(row[0]),prop1:toInt(row[1]),prop2:row[2],prop3:row[3],prop4:row[4]})
6.删除重复关系数据
MATCH (a)-[r:相关公司]->(b) WITH a, b, TAIL (COLLECT (r)) as rr WHERE size(rr)>0
FOREACH (r IN rr | DELETE r)
7.bolt链接报错的时候
Config noSSL = Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig();
Driver driver = GraphDatabase.driver( “bolt://127.0.0.1:7687”, AuthTokens.basic( “neo4j”, “nel4j” ), noSSL );
Session session = driver.session();
8.批量删除
MATCH (n:Node) where n.prop = 'prop' WITH n LIMIT 10000 DELETE n
9.apoc 路径搜索(apoc)
match (startNode:Node{id:'00001'}),(endNode:Node2{id:00002}) CALL apoc.algo.dijkstra(startNode,endNode,'','min_travel_time') YIELD path,weight return path,weight
match (startNode:Node{id:'00001'}),(endNode:Node2{id:00002}) CALL apoc.algo.dijkstra(startNode,endNode,'','distance') YIELD path,weight return path,weight
原文地址:https://www.iteye.com/blog/wcq881215-2432800
a、先删除关系 match (n:Node)-[r:关系名称]-() where (n...条件) delete r
b、删除节点 match (n:Node) where (n...条件) delete n
2.批量更新
:param batch:[{prop1:'property1',prop2:'property2'},{prop1:'property11',prop2:'property22'}]
UNWIND $batch as data MATCH (c:Label1)-[r:关系]->(d:Label2) where c.prop1= data.prop1 and d.prop2=data.prop2 set r.prop= data.prop
3.更新关系名称
.apoc
match (c:DictProduct)-[r:原关系]-(d:DictProduct) with r
call apoc.refactor.setType(r, '新关系') yield input,output return *
4.导出数据
./neo4j-admin dump --database=kg.db --to=../
5.导入数据(dump文件)
./neo4j-admin load --from=./graph.db.dump --database=neo4j.db --force=true
导入数据(csv文件)
using periodic commit 1000 load csv from "http://127.0.0.1:8080/data.csv" as row CREATE (:Node{id:toInt(row[0]),prop1:toInt(row[1]),prop2:row[2],prop3:row[3],prop4:row[4]})
6.删除重复关系数据
MATCH (a)-[r:相关公司]->(b) WITH a, b, TAIL (COLLECT (r)) as rr WHERE size(rr)>0
FOREACH (r IN rr | DELETE r)
7.bolt链接报错的时候
Config noSSL = Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig();
Driver driver = GraphDatabase.driver( “bolt://127.0.0.1:7687”, AuthTokens.basic( “neo4j”, “nel4j” ), noSSL );
Session session = driver.session();
8.批量删除
MATCH (n:Node) where n.prop = 'prop' WITH n LIMIT 10000 DELETE n
9.apoc 路径搜索(apoc)
match (startNode:Node{id:'00001'}),(endNode:Node2{id:00002}) CALL apoc.algo.dijkstra(startNode,endNode,'','min_travel_time') YIELD path,weight return path,weight
match (startNode:Node{id:'00001'}),(endNode:Node2{id:00002}) CALL apoc.algo.dijkstra(startNode,endNode,'','distance') YIELD path,weight return path,weight