orientdb sql api边缘创建在gremlin中不可见

时间:2016-04-13 21:48:00

标签: orientdb gremlin

我有通过console.sh插入边缘的情况,但是当我从gremlin.sh查询时,边缘似乎没有附加到顶点。

首先,通过sql / console.sh创建类:

CREATE CLASS BaseV ABSTRACT EXTENDS V
CREATE PROPERTY BaseV.class  STRING
CREATE PROPERTY BaseV.ID  STRING
CREATE INDEX BaseV.class NOTUNIQUE
CREATE INDEX BaseV.ID NOTUNIQUE
CREATE INDEX BaseVIdx ON BaseV (class, ID) UNIQUE 

CREATE CLASS BaseE ABSTRACT EXTENDS E
CREATE PROPERTY BaseE.class  STRING
CREATE PROPERTY BaseE.ID  STRING
CREATE INDEX BaseE.class NOTUNIQUE
CREATE INDEX BaseE.ID NOTUNIQUE
CREATE INDEX BaseEIdx ON BaseE (class, ID) UNIQUE 

CREATE CLASS User EXTENDS BaseV
CREATE CLASS Comment EXTENDS BaseV
CREATE CLASS Liked EXTENDS BaseE

创建测试顶点和边缘gremlin:

gremlin> g.addVertex('class:User', [class: 'User', ID: '1'])
==>v(testUser)[#-1:-2]
gremlin> g.addVertex('class:Comment', [class: 'Comment', ID: '1'])
==>v(testComment)[#-1:-2]
gremlin> g.commit()
==>null
gremlin> g.V()
==>v(testUser)[#12:0]
==>v(testComment)[#13:0]
gremlin> g.addEdge('class:Liked', g.v('#12:0'), g.v('#13:0'), 'Liked')
==>e[#-1:-2][#12:0-Liked->#13:0]

gremlin> g.commit()
gremlin> g.V()
==>v(testUser)[#12:0]
==>v(testComment)[#13:0]
gremlin> g.V().out
==>v(testComment)[#13:0]

边缘在那里,可通过g.V()输出。现在,通过SQL update / upsert api(con​​sole.sh)插入边缘:

orientdb> select * from Liked

----+-----+------+-----+-----
#   |@RID |@CLASS|out  |in   
----+-----+------+-----+-----
0   |#14:0|Liked |#12:0|#13:0
----+-----+------+-----+-----

1 item(s) found. Query executed in 0.08 sec(s).

orientdb> update liked set class = 'Liked', ID = '1234', out = #12:0, in = #13:0, extra = "updated data" UPSERT WHERE ID = "1234"

Updated record(s) '1' in 0.084000 sec(s).

orientdb> select * from Liked

----+-----+------+-----+-----+-----+----+-----
#   |@RID |@CLASS|out  |in   |class|ID  |extra
----+-----+------+-----+-----+-----+----+-----
0   |#14:0|Liked |#12:0|#13:0|null |null|null 
1   |#14:1|Liked |#12:0|#13:0|Liked|1234|data 
----+-----+------+-----+-----+-----+----+-----

2 item(s) found. Query executed in 0.085 sec(s).

最后,从gremlin.sh查询:

gremlin> g.E()
==>e[#14:0][#12:0-Used->#13:0]
==>e[#14:1][#12:0-Used->#13:0]

边缘显然在那里,但当我遍历它时:

gremlin> g.v('#16:0').outE
==>e[#14:0][#12:0-Liked->#13:0]

'#14:1'应该在那里,但事实并非如此。

0 个答案:

没有答案