orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

expand() function not working properly

Open ghost opened this issue 13 years ago • 8 comments

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: screenshot from 2013-11-27 11 33 26

Only query working correctly is:

select expand(in_AssignedTo.out) from (select expand(out_Owner.in) from User)

screenshot from 2013-11-27 11 37 33

But I think the first one should work like second one.

ghost avatar Nov 27 '13 10:11 ghost

Don't use fields but rather functions to cross the graph:

select expand( out('Owner).in('AssignedTo') ) from user

lvca avatar Nov 27 '13 11:11 lvca

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

ghost avatar Nov 27 '13 13:11 ghost

Yes, but to be safe across OrientDB versions we always suggest users to use graph function ;-)

lvca avatar Nov 27 '13 14:11 lvca

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?

ghost avatar Nov 27 '13 14:11 ghost

I don't know if this works:

select expand( outE('Owner')[@class=PhotoAlbum].inE('AssignedTo')[@class=Photo] ) from user

Otherwise filter with sub-selects.

lvca avatar Nov 27 '13 15:11 lvca

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?

ghost avatar Nov 28 '13 10:11 ghost

or somethingl like that inV('CLASS_NAME'), in('CLASS_NAME') :+1:

deluxxx avatar Dec 02 '13 10:12 deluxxx

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?

lvca avatar Dec 02 '13 13:12 lvca