cgreen
cgreen

Reputation: 351

OrientDB: Select unique vertices but retain the edges

I am trying to do the following weird thing. I have a group of edges that point towards a group of vertices, but there is some repetition - multiple edges point to the same vertices.

Given a SELECT command that gives me the list of edges, I want to:

E.g. the result should be a list of vertices with (vertex rid, [edge 1, edge 2, edge 3]).

Another way to think about this is I want to GROUP BY outgoing vertex but somehow retain in a field the @rid's of all the edges I grouped.

Thanks!

Upvotes: 1

Views: 85

Answers (1)

Michela Bonizzi
Michela Bonizzi

Reputation: 2632

You can try this:

in this you get for every vertex the outgoing edges

select $a.@rid, $a.outE() from 'your class'
let $a = (select from 'your class' where $parent.current.@rid = @rid)

if you want the ingoing vertices you have to change $a.outE() with inE(), like below:

select $a.@rid, $a.inE() from 'your class'
let $a = (select from 'your class' where $parent.current.@rid = @rid)

Hope it helps.

Regards.

Upvotes: 1

Related Questions