0
votes

I am using orient 2.1-rc4, executed the following commands: My motive is to fetch only the outgoing vertices path.

1. Correct Result with Simple Graph

create class Depends extends E
create vertex set name="persians"
create vertex set name="vikings" 
create vertex set name="teutons"
create vertex set name="mayans" 
create vertex set name="aztecs"

select * from v

\#   |@RID|@CLASS|name    
0   |#9:0|V     |persians
1   |#9:1|V     |vikings 
2   |#9:2|V     |teutons 
3   |#9:3|V     |mayans  
4   |#9:4|V     |aztecs  

create edge Depends from #9:0 to #9:2
create edge Depends from #9:1 to #9:2
create edge Depends from #9:2 to #9:3
create edge Depends from #9:2 to #9:4

SELECT @this.toJSON('fetchPlan:in_*:-2 *:-1') FROM #9:2

{"out_Depends":[{"out":"#9:2","in":{"name":"mayans","in_Depends":["#11:2"]}},{"out":"#9:2","in":{"name":"aztecs","in_Depends":["#11:3"]}}],"name":"teutons"}

Only the outgoing nodes are fetched as expected.

2. Incorrect result

Adding two more vertices:

create vertex set name="britons"                       
create vertex set name="mongols"
create edge Depends from #9:5 to #9:0
create edge Depends from #9:6 to #9:4

select * from e
----+-----+-------+----+----
\#   |@RID |@CLASS |out |in  
----+-----+-------+----+----
0   |#11:0|Depends|#9:0|#9:2
1   |#11:1|Depends|#9:1|#9:2
2   |#11:2|Depends|#9:2|#9:3
3   |#11:3|Depends|#9:2|#9:4
4   |#11:4|Depends|#9:5|#9:0
5   |#11:5|Depends|#9:6|#9:4
----+-----+-------+----+----

Trying to fetch the out vertices as per http://orientdb.com/docs/last/Fetching-Strategies.html

SELECT @this.toJSON('fetchPlan:in_*:-2') FROM #9:2
{"out_Depends":["#11:2","#11:3"],"name":"teutons"}

Not all out vertices are fetched

SELECT @this.toJSON('fetchPlan:in_*:-2 *:-1') FROM #9:2
{"out_Depends":[{"out":"#9:2","in":{"name":"mayans","in_Depends":["#11:2"]}},{"out":"#9:2","in":{"in_Depends":["#11:3",{"out":{"name":"mongols","out_Depends":["#11:5"]},"in":"#9:4"}],"name":"aztecs"}}],"name":"teutons"}

Extra vertex mongols fetched, which means the rule has not being applied at other levels. (out_Depends is excluded only from the 0th level)

Adding a [*] to apply the exclusion rule on all levels as per the documentation

SELECT @this.toJSON('fetchPlan:[*]in_*:-2 *:-1') FROM #9:2
{"out_Depends":[{"out":"#9:2","in":{"name":"mayans","in_Depends":["#11:2"]}},{"out":"#9:2","in":{"in_Depends":["#11:3",{"out":{"name":"mongols","out_Depends":["#11:5"]},"in":"#9:4"}],"name":"aztecs"}}],"in_Depends":[{"out":{"name":"persians","out_Depends":["#11:0"],"in_Depends":[{"out":{"name":"britons","out_Depends":["#11:4"]},"in":"#9:0"}]},"in":"#9:2"},{"out":{"name":"vikings","out_Depends":["#11:1"]},"in":"#9:2"}],"name":"teutons"}

This however fetches the entire tree. Can someone give a suggestion?

1
Hey, I am having the same issue... did you find any solution? - BkdD
No, I opened up an issue on orients github too, I think it's not been addressed - user3423347

1 Answers

0
votes

I followed your instructions and your query works, can you post the graph's image of your db,please?