OrientDB Query Result set of vertices with an empty collection of edges, vertices

207 views Asked by At

this might be a simple question but I am confused, please help.....

I am using OrientDB 2.1.9 and I am experimenting with VehicleHistoryGraph database. From Studio, Browse mode, set limit to 9 records only. Now I am entering this simple query

select out() from Person

The result set I am getting back is 9 records BUT only two have Bought a vehicle. The rest are displayed with empty collections []. This is no good, I am confused. I would expect to get back only those two vertices with collections of edges !

How do I get back these two persons that bought something ? I noticed also that there is this unwind operator in select. Is this useful in that case, can you make an example ?

1

There are 1 answers

1
peak On

Your query asks for out(), so out() is computed in all cases, and you're shown the results. If you only want the rows for which out().size() > 0 then you can construct a query like this:

select out() from v let n=out().size() where $n > 0

If you think that one ought to be able to write this more succintly, e.g. like so:

select out() as n from v where n > 0

then join the club (e.g. by supporting this enhancement request).

(select out() from v where out().size() > 0 is supported.)