Best query to get all related vertices through an Edge?

50 views
Skip to first unread message

Quốc Nam Lê

unread,
Aug 16, 2016, 12:32:22 AM8/16/16
to OrientDB
In my case, I have 2 vertices and 1 edge follow:
Post (#10:1) ----> HasComments -----> Comment (#11:1, #11:2, ...)
 (V)   out          (E)              (in)       (V)

So, What is the best query (speed, performance) to get all Comments from a Post through HasComments?
Here is my query:

SELECT EXPAND(OUT('HasComments')) FROM #10:1

alessand...@gmail.com

unread,
Aug 16, 2016, 3:10:11 AM8/16/16
to OrientDB
Hi,
I think that
SELECT EXPAND(OUT('HasComments')) FROM #10:1

is the best query to get all Comments from a Post through HasComments

Kind regards,
Alessandro

Quốc Nam Lê

unread,
Aug 16, 2016, 5:49:53 AM8/16/16
to OrientDB
Thank for your response.
Any idea?

Quốc Nam Lê

unread,
Aug 29, 2016, 10:57:47 PM8/29/16
to OrientDB
I have another question.
I want to see all properties of Comment vertex, and Record ID of Post vertex in query result.
So, I try to run select statement:

SELECT EXPAND(OUT('HasComments')), @rid as post_id FROM #10:1

But this statememt is wrong.
Please tell me how to do this.

Oleksandr Gubchenko

unread,
Aug 29, 2016, 11:11:27 PM8/29/16
to OrientDB
You need to specify each property name after the edge name: OUT('HasComments')).property1, OUT('HasComments')).property2
etc

Quốc Nam Lê

unread,
Aug 29, 2016, 11:52:52 PM8/29/16
to OrientDB
I don't know what's properties of Comment vertex, so which's another way to do this?

alessand...@gmail.com

unread,
Aug 30, 2016, 4:24:02 AM8/30/16
to orient-...@googlegroups.com
Hi,
you could use 

select *,$a.rid from (SELECT EXPAND(OUT('HasComments')) FROM #10:1)
let $a
= (select @rid from #10:1)

or

select *,$a.rid from (SELECT EXPAND(OUT('HasComments')) FROM #10:1
let $a
= (select @rid from $parent.$current))


Hope it helps
Reply all
Reply to author
Forward
0 new messages