Search code examples
sqlgraph-databasesorientdb

How to sort vertices by edge count in OrientDB


I want to do this but it doesn't work:

select * FROM Users ORDER BY in.size() 

I have also tried:

select * from Users ORDER BY in[label='connection'].size()
select * from Users ORDER BY inE['connection'].size()

it just returns all V's but not sorted


Solution

  • This is probably more what you were looking for.

    select *, in().size() as size from Users order by size desc
    

    My understanding is that that will take all incoming edges into the count. If you only need to look at a specific edge, try the following.

    select *, in_myEdge.size() as size from Users order by size desc
    

    However, if you use the wrong edge name, the query won't give you and error and simply return a bogus result.

    ORDER BY is currently supported only on projection fields and will be a feature in future releases.