https://github.com/lflxp/studyneo4j
study neo4j api
https://github.com/lflxp/studyneo4j
Last synced: 6 months ago
JSON representation
study neo4j api
- Host: GitHub
- URL: https://github.com/lflxp/studyneo4j
- Owner: lflxp
- Created: 2019-01-21T04:57:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-24T18:59:47.000Z (over 7 years ago)
- Last Synced: 2025-07-21T15:44:37.087Z (about 1 year ago)
- Language: HTML
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# studyNeo4j
study neo4j api
# 导入基础数据
LOAD CSV WITH HEADERS FROM "http://192.168.40.204:8888/group.csv" as row
create (n:Group)
set n = row
LOAD CSV WITH HEADERS FROM "http://192.168.40.204:8888/host.csv" as row
create (a:Host)
set a = row
LOAD CSV WITH HEADERS FROM "http://192.168.40.204:8888/person.csv" as row
create (b:Person)
set b = row
LOAD CSV WITH HEADERS FROM "http://192.168.40.204:8888/service.csv" as row
create (c:Service)
set c = row
# 创建关系
张三
李四
王五
周期
李想
冉伊
材质鹏
吕集
## 人员关系 普通员工
match (n:Person),(m:Group)
where n.name in ['张三','王五','冉伊'] and m.group="云平台"
create (n)-[:BELONG {role:['普通员工']}]->(m)
## 人员关系 管理员
match (n:Person),(m:Group)
where n.name in ['材质鹏'] and m.group="云平台"
create (n)-[:BELONG {role:['管理员']}]->(m)
## 人员关系 管理员
match (n:Person),(m:Group)
where n.name in ['材质鹏','李想'] and m.group="运维"
create (n)-[:BELONG {role:['管理员']}]->(m)
match (n:Person),(m:Group)
where n.name in ['李四','周期'] and m.group="安防"
create (n)-[:BELONG {role:['员工']}]->(m)
match (n:Person),(m:Group)
where n.name in ['李四','吕集'] and m.group="dba"
create (n)-[:BELONG {role:['员工']}]->(m)
match (n:Person),(m:Group)
where n.name in ['李四','吕集','李想'] and m.group="基础平台"
create (n)-[:BELONG {role:['员工']}]->(m)
match (n:Person),(m:Group)
where n.name in ['冉伊'] and m.group="人事"
create (n)-[:BELONG {role:['员工']}]->(m)
match (n:Person),(m:Group)
where n.name in ['王五'] and m.group="创新"
create (n)-[:BELONG {role:['员工']}]->(m)
match (n:Person),(m:Group)
where n.name in ['周期'] and m.group="研发"
create (n)-[:BELONG {role:['员工']}]->(m)
# 设置Service到host
match (a:Host),(b:Service)
where b.ip=a.ip
create (b)-[:Deploy {type:"install"}]->(a)
return a,b
# 设置host到group
match (h:Host),(g:Group)
where h.hostname in ['hostname1',
'hostname11',
'hostname21',
'hostname31',
'hostname41',
'hostname51',
'hostname61',
'hostname71',
'hostname81',
'hostname91'] and g.group='研发'
create (h)-[:分配]->(g)
return h,g
match (h:Host),(g:Group)
where h.hostname in ['hostname2',
'hostname12',
'hostname22',
'hostname32',
'hostname42',
'hostname52',
'hostname62',
'hostname72',
'hostname82',
'hostname92'] and g.group='运维'
create (h)-[:分配]->(g)
return h,g
match (h:Host),(g:Group)
where h.hostname in ['hostname3',
'hostname13',
'hostname23',
'hostname33',
'hostname43',
'hostname53',
'hostname63',
'hostname73',
'hostname83',
'hostname93'] and g.group='安防'
create (h)-[:分配]->(g)
return h,g
match (h:Host),(g:Group)
where h.hostname in ['hostname4',
'hostname14',
'hostname24',
'hostname34',
'hostname44',
'hostname54',
'hostname64',
'hostname74',
'hostname84',
'hostname94'] and g.group='创新'
create (h)-[:分配]->(g)
return h,g
match (h:Host),(g:Group)
where h.hostname in ['hostname5',
'hostname15',
'hostname25',
'hostname35',
'hostname45',
'hostname55',
'hostname65',
'hostname75',
'hostname85',
'hostname95'] and g.group='人事'
create (h)-[:分配]->(g)
return h,g
match (h:Host),(g:Group)
where h.hostname in ['hostname6',
'hostname16',
'hostname26',
'hostname36',
'hostname46',
'hostname56',
'hostname66',
'hostname76',
'hostname86',
'hostname96'] and g.group='基础平台'
create (h)-[:分配]->(g)
return h,g
match (h:Host),(g:Group)
where h.hostname in ['hostname7',
'hostname17',
'hostname27',
'hostname37',
'hostname47',
'hostname57',
'hostname67',
'hostname77',
'hostname87',
'hostname97'] and g.group='云平台'
create (h)-[:分配]->(g)
return h,g
match (h:Host),(g:Group)
where h.hostname in ['hostname8',
'hostname18',
'hostname28',
'hostname38',
'hostname48',
'hostname58',
'hostname68',
'hostname78',
'hostname88',
'hostname98'] and g.group='dba'
create (h)-[:分配]->(g)
return h,g
# 修改关系 添加属性
match (n)-[r:Deploy]->(a)
set r.desc='部署'
# 批量关系 csv
# 权限表
create (n:Privileges{name:'管理员',desc:'admin'})
create (b:Privileges{name:'员工',desc:'worker'})
create (c:Privileges{name:'游客',desc:'guest'})
match (a:Person),(p:Privileges)
where a.name in ['张三'] and p.name='管理员'
create (a)-[:Privileges]->(p)
return a,p
match (a:Person),(p:Privileges)
where a.name in ['李四','王五','周期','李想','冉伊'] and p.name='员工'
create (a)-[:Privileges]->(p)
return a,p
match (a:Person),(p:Privileges)
where a.name in ['吕集','材质鹏'] and p.name='游客'
create (a)-[:Privileges]->(p)
return a,p
# 查询
match (c)-[:Privileges]->(a)-[:BELONG]->(m)<-[:分配]-(n) return a,m,n,c