GithubHelp home page GithubHelp logo

studyneo4j's Introduction

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

studyneo4j's People

Contributors

lflxp avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.