Neo4j筆記
Baisc Query
Create
新增node並同時增添屬性
新增並返回查詢CREATE
n = {name :
'Andres'
, title :
'Developer'
}
新增relationship並增添屬性CREATE
(a {name :
'Andres'
})
RETURN
a
START
a=
node
(1), b=
node
(2)
CREATE
a-[r:RELTYPE {name : 'like'
}]->b
RETURN
r
Search
利用id查詢node複數個nodeSTART
n=
node
(1)
RETURN
n
搜尋複數個node於一列START
n=
node
(1, 2, 3)
RETURN
n
START
a=
node
(1), b=
node
(2)
RETURN
a,b
全部
查詢relationshipSTART
n=
node
(*)
RETURN
n
利用index查詢 node或者relationship,注意nodes及rels代表是index的名子START
r=
relationship
(0)
RETURN
r
START
n=
node
:
nodes
(name =
"A"
)
RETURN
n
START
r=
relationship
:rels(name =
"Andrés"
)
RETURN
r
Match
查詢跟node3有關聯的node指定方向性(由node3出去的)START
n=
node
(3)
MATCH
(n)--(x)
RETURN
x
查詢與node有關聯的relationship,返回relationshipSTART
n=
node
(3)
MATCH
(n)-->(x)
RETURN
x
一樣返回 relationship,但是限定為BLOCKSSTART
n=
node
(3)
MATCH
(n)-[r]->()
RETURN
r
BLOCKS或KNOWS都行START
n=
node
(3)
MATCH
(n)-[r:BLOCKS]->()
RETURN
r
指向node3START
n=
node
(3)
MATCH
(n)-[r:BLOCKS|KNOWS]->()
RETURN
r
限定relationship為BLOCKS,返回nodeSTART
n=
node
(3)
MATCH
(n)<-[r:BLOCKS|KNOWS]-()
RETURN
r
接下來這個Case比較特殊,查詢node3,2,4並且其關聯為KNOWS,此外關聯可以允數的層數為第一層到第三層,所以即使node3並沒有與node4有KNOWS的關聯,但是因為node4與node2有KNOW的關聯,所以也在符合條件的範圍內。START
n=
node
(3)
MATCH
(n)-[:BLOCKS]->(x)
RETURN
x
限制與a關聯為LOVESSTART
a=
node
(3), x=
node
(2, 4)
MATCH
a-[:KNOWS*1..3]->x
RETURN
a,x
START
a=
node
(3)
MATCH
a-[r?:LOVES]->()
RETURN
a,r
兩點之間最短路徑,限制在15層內
或者是所有START
d=
node
(1), e=
node
(2)
MATCH
p =
allShortestPaths
( d-[*..15]->e )
RETURN
p
START
d=
node
(1), e=
node
(2)
MATCH
p =
allShortestPaths
( d-[*..15]->e )
RETURN
p
以上資料來源
這東西從我想要拿來試到現在已經有8,9個月了,果然執行力還是不夠,不過幸好我記性好...。花了快兩個小時k這些東西,不過花這時間是值得的,看來把這資料庫拿來儲存pathway鈽但方便使用,而且要做搜尋也更方便更直覺。
這禮拜五已經把KEGG的Parser用XML::SAX大概寫完了,接下來就是要看怎樣把資料塞進去了。
About Me
- Unknown
Category List
- aircraft (1)
- Android (1)
- aviation (3)
- aws (1)
- biology (1)
- blogger (1)
- c++ (1)
- css (1)
- DBIx::Class (1)
- ds (1)
- english (6)
- git (1)
- google code (1)
- java (1)
- joe (1)
- json (1)
- language (1)
- livereload (1)
- math (1)
- mojolicious (1)
- murmur (1)
- neo4j (2)
- pdb (1)
- perl (10)
- personal (9)
- running (11)
- stock (1)
- sublime2 (2)
- swimming (1)
- talk (2)
- TheSchwartz (1)
- unicode (1)
- utf8 (1)
- web_design (1)
- work (1)
Followers
Total Pageviews
Labels
- aircraft (1)
- Android (1)
- aviation (3)
- aws (1)
- biology (1)
- blogger (1)
- c++ (1)
- css (1)
- DBIx::Class (1)
- ds (1)
- english (6)
- git (1)
- google code (1)
- java (1)
- joe (1)
- json (1)
- language (1)
- livereload (1)
- math (1)
- mojolicious (1)
- murmur (1)
- neo4j (2)
- pdb (1)
- perl (10)
- personal (9)
- running (11)
- stock (1)
- sublime2 (2)
- swimming (1)
- talk (2)
- TheSchwartz (1)
- unicode (1)
- utf8 (1)
- web_design (1)
- work (1)