共計(jì) 2341 個(gè)字符,預(yù)計(jì)需要花費(fèi) 6 分鐘才能閱讀完成。
這篇文章主要介紹“Neo4j 是什么”,在日常操作中,相信很多人在 Neo4j 是什么問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對(duì)大家解答”Neo4j 是什么”的疑惑有所幫助!接下來,請(qǐng)跟著丸趣 TV 小編一起來學(xué)習(xí)吧!
Neo4j 是開源的,分了多個(gè)版本,其中企業(yè)版是基于 AGPL 協(xié)議的。
也就意味著你需要擴(kuò)展,需要補(bǔ)充一個(gè)協(xié)議。
Neo4j 的版本也分了不同的平臺(tái),目前較新的版本是 3.3,最新的 3.4
Neo4j 比較貼心的是下載的時(shí)候會(huì)提示你注冊一個(gè)用戶,注冊之后,會(huì)給你發(fā)送一個(gè)電子版的 pdf 文檔。有一些詳細(xì)的技術(shù)細(xì)節(jié)。
下載 Neo4j 其實(shí)會(huì)很多的選擇,有很多的組件可下載。其中 Cypher 學(xué)習(xí) Neo4j 的重中之重。限于時(shí)間關(guān)系,我就學(xué)了幾個(gè)花拳繡腿。
因?yàn)?Neo4j 是基于 Java, 所以使用 Java 來做數(shù)據(jù)的處理還是很方便的,當(dāng)然他也支持不同平臺(tái)的語言和技術(shù)。
我們來簡單實(shí)踐一下。
首先從官網(wǎng)下載 Neo4j, 安裝包大概是 80M 左右。
因?yàn)?Neo4j 是基于 Java 開發(fā),我選擇的版本是 3.3,能夠接受的最低版本是 1.8 了。所以在安裝配置的時(shí)候我們需要提前準(zhǔn)備好 Java.
然后在 bin 目錄下啟動(dòng) Neo4j, 有兩種方式,一種是使用 console 選項(xiàng),一種是 start 基于后臺(tái)模式。
啟動(dòng)的日志如下:
[root@dev01 bin]# ./neo4j console
Active database: graph.db
Directories in use:
home: /root/neo4j/neo4j-community-3.3.2
config: /root/neo4j/neo4j-community-3.3.2/conf
logs: /root/neo4j/neo4j-community-3.3.2/logs
plugins: /root/neo4j/neo4j-community-3.3.2/plugins
import: /root/neo4j/neo4j-community-3.3.2/import
data: /root/neo4j/neo4j-community-3.3.2/data
certificates: /root/neo4j/neo4j-community-3.3.2/certificates
run: /root/neo4j/neo4j-community-3.3.2/run
Starting Neo4j.
WARNING: Max 1024 open files allowed, minimum of 40000 recommended. See the Neo4j manual.
2018-01-23 15:12:55.972+0000 INFO ======== Neo4j 3.3.2 ========
2018-01-23 15:12:56.010+0000 INFO Starting…
2018-01-23 15:12:57.425+0000 INFO Bolt enabled on 127.0.0.1:7687.
2018-01-23 15:13:01.078+0000 INFO Started.
2018-01-23 15:13:02.240+0000 INFO Remote interface available at http://localhost:7474/
我們可以使用提供的 url 來連接,默認(rèn)的密碼是 neo4j, 第一次登錄之后會(huì)提示你修改密碼。
然后我們可以基于 cypher-shell 的命令行方式來學(xué)習(xí) neo4j 或者圖形的方式都可以。
如果要連接到 Neo4j,使用 cypher-shell 的方式如下:
[root@dev01 bin]# ./cypher-shell
username: neo4j
password: *******
Connected to Neo4j 3.3.2 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.
我們創(chuàng)建數(shù)據(jù)
neo4j CREATE (A {id:1,name: A}), (B {id:2,name: B}), (C
{id:3,name: C}), (D {id:4,name: D}),(E
{id:5,name: E}),(A)-[:Son]- (B),(A)-[:Son]- (C),(B)-[:Son]- (D),(C)-[:Son]-
0 rows available after 226 ms, consumed after another 0 ms
Added 5 nodes, Created 4 relationships, Set 10 properties
遍歷,得到關(guān)系
neo4j START n=node(*) RETURN n;
+———————-+
| n |
+———————-+
| ({name: A , id: 1}) |
| ({name: B , id: 2}) |
| ({name: C , id: 3}) |
| ({name: D , id: 4}) |
| ({name: E , id: 5}) |
+———————-+
5 rows available after 1385 ms, consumed after another 18 ms
neo4j
如果是通過終端的方式,就更方便了。
直接在里面輸入信息,就可以得到圖形的結(jié)果了。
到此,關(guān)于“Neo4j 是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注丸趣 TV 網(wǎng)站,丸趣 TV 小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!