linux neo4j使用

解压到/opt/下

 tar zxvf /tmp/neo4j-community-3.4.10-unix.tar.gz -C /opt/

 cd /opt/neo4j-community-3.4.10/

 cd bin/

 ./neo4j start

 ./neo4j status

 ./neo4j-shell   -path /opt/neo4j-community-3.4.10/

建议使用cypher-shell

./cypher-shell

username: neo4j

默认密码neo4j

password: *****

Connected to Neo4j 3.4.10 at bolt://localhost:7687 as user neo4j.

Type :help for a list of available commands or :exit to exit the shell.

Note that Cypher queries must end with a semicolon.

neo4j>

需要修改密码

CALL dbms.changePassword('test')

 

neo4j> match (n) return n;

0 rows available after 10 ms, consumed after another 1 ms

neo4j> create (p:Person {name:'zhangsan'}) return p;

+------------------------------+

| p                            |

+------------------------------+

| (:Person {name: "zhangsan"}) |

+------------------------------+

 

1 row available after 172 ms, consumed after another 0 ms

Added 1 nodes, Set 1 properties, Added 1 labels

neo4j> match (n) return n;

+------------------------------+

| n                            |

+------------------------------+

| (:Person {name: "zhangsan"}) |

+------------------------------+

 

1 row available after 2 ms, consumed after another 1 ms

neo4j>  create (p:Person {name:'lisi'}) return p;

+--------------------------+

| p                        |

+--------------------------+

| (:Person {name: "lisi"}) |

+--------------------------+

 

1 row available after 26 ms, consumed after another 0 ms

Added 1 nodes, Set 1 properties, Added 1 labels

neo4j>  match (p:Person {name:'lisi'}), (q:Person {name:'zhangsan'}) create (p)-[r:Friend {name:'is_friend'}]->(q) return r;

+-------------------------------+

| r                             |

+-------------------------------+

| [:Friend {name: "is_friend"}] |

+-------------------------------+

 

1 row available after 276 ms, consumed after another 0 ms

Created 1 relationships, Set 1 properties

neo4j> match (n)-[*]-(p) return n,p;

+-------------------------------------------------------------+

| n                            | p                            |

+-------------------------------------------------------------+

| (:Person {name: "lisi"})     | (:Person {name: "zhangsan"}) |

| (:Person {name: "zhangsan"}) | (:Person {name: "lisi"})     |

+-------------------------------------------------------------+

 

2 rows available after 130 ms, consumed after another 21 ms

neo4j>

使用正则匹配:

neo4j> match (n)-[r:Friend]-(p) where p.name=~'li.*' return n,p,r.name,p.name;

+--------------------------------------------------------------------------------+

| n                            | p                        | r.name      | p.name |

+--------------------------------------------------------------------------------+

| (:Person {name: "zhangsan"}) | (:Person {name: "lisi"}) | "is_friend" | "lisi" |

+--------------------------------------------------------------------------------+

 

1 row available after 34 ms, consumed after another 1 ms

neo4j> match (n)-[r:Friend]-(p) where p.name=~'li.*' and type(r)=~"F.*" return n,p,r.name,p.name;

+--------------------------------------------------------------------------------+

| n                            | p                        | r.name      | p.name |

+--------------------------------------------------------------------------------+

| (:Person {name: "zhangsan"}) | (:Person {name: "lisi"}) | "is_friend" | "lisi" |

+--------------------------------------------------------------------------------+

 

1 row available after 82 ms, consumed after another 0 ms

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值