expand() function not working properly
Environment: OrientDB 1.6.1 on Ubuntu Linux
I have this scipt:
CREATE CLASS User EXTENDS V;
CREATE PROPERTY User.name STRING;
CREATE CLASS PhotoAlbum EXTENDS V;
CREATE PROPERTY PhotoAlbum.name STRING;
CREATE CLASS Photo EXTENDS V;
CREATE PROPERTY Photo.name STRING;
CREATE CLASS Owner EXTENDS E;
CREATE CLASS AssignedTo EXTENDS E;
CREATE VERTEX User SET name="user1";
CREATE VERTEX PhotoAlbum SET name="photoAlbum1";
CREATE VERTEX PhotoAlbum SET name="photoAlbum2";
CREATE VERTEX Photo SET name="photo1";
CREATE VERTEX Photo SET name="photo2";
CREATE VERTEX Photo SET name="photo3";
CREATE EDGE Owner FROM (Select from User where name="user1") TO (Select from PhotoAlbum where name="photoAlbum1");
CREATE EDGE Owner FROM (Select from User where name="user1") TO (Select from PhotoAlbum where name="photoAlbum2");
CREATE EDGE AssignedTo FROM (Select from Photo where name="photo1") TO (Select from PhotoAlbum where name="photoAlbum1");
CREATE EDGE AssignedTo FROM (Select from Photo where name="photo2") TO (Select from PhotoAlbum where name="photoAlbum1");
CREATE EDGE AssignedTo FROM (Select from Photo where name="photo3") TO (Select from PhotoAlbum where name="photoAlbum2");
When I execute query:
select expand(out_Owner.in.in_AssignedTo.out) from User
I get 2 result (but should be 3), this happen because properties are not expanded properly. Look at attached screenshot:

Only query working correctly is:
select expand(in_AssignedTo.out) from (select expand(out_Owner.in) from User)

But I think the first one should work like second one.
Don't use fields but rather functions to cross the graph:
select expand( out('Owner).in('AssignedTo') ) from user
Thanks for suggestion. I also found another workaround: we can use list() function and everything is working fine:
select expand( list(out_Owner.in.in_AssignedTo.out) ) from User
Yes, but to be safe across OrientDB versions we always suggest users to use graph function ;-)
Ok but what if I want to filter by Vertex class names (not Edges names like it was in previous query you used)
Example in my approach:
select expand( list(out_Owner.in[@class=PhotoAlbum].in_AssignedTo.out[@class=Photo]) ) from User
Can you suggest me how to build this query using graph functions?
I don't know if this works:
select expand( outE('Owner')[@class=PhotoAlbum].inE('AssignedTo')[@class=Photo] ) from user
Otherwise filter with sub-selects.
Unfortunately your example is not working :( This is why I use fields rather than functions (because of the [] operator). Maybe it is possible to implement such enhancement (so functions with [] operator will work) in future releases?
or somethingl like that inV('CLASS_NAME'), in('CLASS_NAME') :+1:
Current parser is a bit stupid. We're waiting for the Johann's contribution in 2.0 but seems hard to convince him to complete the pending job... So probably we should live with the current parser for more time.
Operator [] should be allowed in chain like other calls, so please could you open a new issue for that?