NEO4J导入数据备忘

学习链接:https://neo4j.com/docs/operations-manual/current/tutorial/neo4j-admin-import/

bin\neo4j-admin import --database=neo4j --skip-bad-relationships --skip-duplicate-nodes --nodes=import\nuget_all_releases.csv --relationships=import\nuget_project_dependencies.csv,import\nuget_project_dependencies2.csv

带有头节点:

bin/neo4j-admin import --database=neo4j --nodes=import/movies4-header.csv,import/movies4-part1.csv,import/movies4-part2.csv --nodes=import/actors4-header.csv,import/actors4-part1.csv,import/actors4-part2.csv --relationships=import/roles4-header.csv,import/roles4-part1.csv,import/roles4-part2.csv

 

备份:

bin\neo4j-admin import  --skip-bad-relationships --skip-duplicate-nodes --database=neo4j --nodes=D:\Neo4j\WorkPlace\CSV\NuFix\backups\nuget_all_releases.csv --relationships=D:\Neo4j\WorkPlace\CSV\NuFix\backups\nuget_project_dependencies_header.csv,D:\Neo4j\WorkPlace\CSV\NuFix\backups\nuget_project_dependencies200.csv,D:\Neo4j\WorkPlace\CSV\NuFix\backups\nuget_project_dependencies300.csv,D:\Neo4j\WorkPlace\CSV\NuFix\backups\nuget_project_dependencies450.csv,D:\Neo4j\WorkPlace\CSV\NuFix\backups\nuget_project_dependencies500.csv,D:\Neo4j\WorkPlace\CSV\NuFix\backups\nuget_project_dependencies600.csv,D:\Neo4j\WorkPlace\CSV\NuFix\backups\nuget_project_dependencies700.csv

 

建立索引:

create text index node_package_version for (n:Package) on (n.version)

create text index node_package_package_name for (n:Package) on (n.package_name)

create text index node_package_id for (n:Package) on (n.packageID)
create text index node_package_is_perelease for (n:Package) on (n.isPrerelease)
create text index relationship_framework for ()-[r:Target_To]-() on(r.targetFramework)
 
更改成全文索引:
CREATE FULLTEXT INDEX full_node_packageID FOR (n:Package) ON EACH  [n.packageID] OPTIONS {indexConfig: {`fulltext.analyzer`: 'url_or_email', `fulltext.eventually_consistent`: true}}
CREATE FULLTEXT INDEX full_ral_targetframework FOR ()-[r:Target_To]->() ON EACH [r.targetFramework] OPTIONS {indexConfig: {`fulltext.analyzer`: 'url_or_email', `fulltext.eventually_consistent`: true}}
 
全文索引查询:
CALL db.index.fulltext.queryNodes("full_node_packageID  ", '"newtonsoft.json@@9.0.1"') YIELD node, score
with node as a,score
where (a)-[r:Target_To*1..5]->(m:Package) and all(a in r where a.targetFramework contains "Standard") and not (m)-[]->() and all (mm in nodes(p) where mm.isPrerelease ="False")
RETURN reduce(node_ids = [], n IN nodes(p) | node_ids + [n]) as result
 
 
 
测验查询:
CALL db.index.fulltext.queryNodes("full_node_packageID", '"newtonsoft.json@@9.0.1"') YIELD node, score 
with node as n,score
optional match p=(n)-[r:Target_To*1..5]->(m:Package)
where all(a in r where a.targetFramework contains "Standard") 
       and not (m)-[]->() 
       and all (mm in nodes(p) where mm.isPrerelease ="False")
RETURN reduce(node_ids = [], n IN nodes(p) | node_ids + [n]) as result
 
 
服务器备忘

neo4j-admin import --skip-bad-relationships --skip-duplicate-nodes --database=neo4j --nodes=/var/lib/neo4j/import/nuget_all_releases.csv
--relationships=/var/lib/neo4j/import/nuget_project_dependencies_header.csv,/var/lib/neo4j/import/nuget_project_dependencies796.csv,/var/lib/neo4j/import/nuget_project_dependencies700.csv,
/var/lib/neo4j/import/nuget_project_dependencies600.csv,/var/lib/neo4j/import/nuget_project_dependencies500.csv,/var/lib/neo4j/import/nuget_project_dependencies450.csv,
/var/lib/neo4j/import/nuget_project_dependencies300.csv,/var/lib/neo4j/import/nuget_project_dependencies200.csv,/var/lib/neo4j/import/nuget_project_dependencies106.csv,
/var/lib/neo4j/import/nuget_project_dependencies100.csv

 

LOAD CSV:

load csv from 'file:///nuget_project_dependencies450.csv' as line
match (n:Package{packageID:line[0]}), (m:Package{packageID:line[2]})
merge (n)-[r:Target_To{targetFramework:line[1]}]->(m)
return count(r)
 
 
权限管理:
命名新标签的能力
GRANT NAME MANAGEMENT ON DATABASE * TO reader 
给角色设置标签的权限
GRANT SET LABEL * ON GRAPH neo4j TO regularUsers
属性设置权限
GRANT SET PROPERTY {*} ON HOME GRAPH NODES * TO regularUsers
创建用户:
CREATE USER jake SET PASSWORD 'abc'
给用户赋予角色:
GRANT ROLE myrole TO bob
posted @ 2022-06-09 20:41  博二爷  阅读(73)  评论(0编辑  收藏  举报